2020-05-17 11:30:00 -07:00
|
|
|
/*
|
2020-06-18 05:18:53 -07:00
|
|
|
* Copyright 2018-2019. Alastair Roy Poole <netstar@gmail.com>
|
2019-10-05 03:49:03 -07:00
|
|
|
*
|
2020-07-11 10:47:24 -07:00
|
|
|
* See COPYING file for details.
|
2018-10-02 07:38:06 -07:00
|
|
|
*/
|
2018-06-17 00:45:46 -07:00
|
|
|
|
2020-06-18 07:36:39 -07:00
|
|
|
#define DEVELOPMENT 1
|
|
|
|
|
2019-12-10 15:17:16 -08:00
|
|
|
#include "config.h"
|
2020-05-12 16:51:30 -07:00
|
|
|
#include "evisum_config.h"
|
|
|
|
#include "ui/ui.h"
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2020-06-18 07:36:39 -07:00
|
|
|
#if defined(DEVELOPMENT)
|
|
|
|
# include "system/machine.h"
|
|
|
|
# include "system/process.h"
|
|
|
|
# include "system/disks.h"
|
|
|
|
# include "system/filesystems.h"
|
|
|
|
#endif
|
|
|
|
|
2018-06-04 03:11:21 -07:00
|
|
|
static void
|
2020-05-23 05:51:26 -07:00
|
|
|
_win_del_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2020-06-30 05:05:35 -07:00
|
|
|
Ui *ui = data;
|
|
|
|
|
|
|
|
evisum_ui_shutdown(ui);
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2020-02-15 07:30:31 -08:00
|
|
|
static Ui *
|
2018-06-04 03:11:21 -07:00
|
|
|
_win_add(void)
|
|
|
|
{
|
2018-06-16 13:31:49 -07:00
|
|
|
Ui *ui;
|
2018-06-04 03:11:21 -07:00
|
|
|
Evas_Object *win, *icon;
|
|
|
|
|
|
|
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
2018-06-05 07:26:18 -07:00
|
|
|
win = elm_win_util_standard_add("evisum", "evisum");
|
2018-06-04 03:11:21 -07:00
|
|
|
icon = elm_icon_add(win);
|
2018-06-07 02:30:03 -07:00
|
|
|
elm_icon_standard_set(icon, "evisum");
|
2018-06-04 03:11:21 -07:00
|
|
|
elm_win_icon_object_set(win, icon);
|
2020-06-28 12:04:03 -07:00
|
|
|
evas_object_resize(win, EVISUM_WIN_WIDTH * elm_config_scale_get(),
|
|
|
|
EVISUM_WIN_HEIGHT * elm_config_scale_get());
|
2020-05-24 05:47:48 -07:00
|
|
|
elm_win_title_set(win, _("EFL System Monitor"));
|
2018-06-16 13:31:49 -07:00
|
|
|
elm_win_center(win, EINA_TRUE, EINA_TRUE);
|
|
|
|
|
2020-05-13 05:15:58 -07:00
|
|
|
ui = evisum_ui_add(win);
|
2019-09-05 14:33:38 -07:00
|
|
|
if (!ui)
|
2020-02-15 07:30:31 -08:00
|
|
|
return NULL;
|
2019-09-05 14:33:38 -07:00
|
|
|
|
2020-10-03 07:44:32 -07:00
|
|
|
ui->state.shutdown_now = EINA_TRUE;
|
2020-06-30 05:23:01 -07:00
|
|
|
|
2018-06-16 13:31:49 -07:00
|
|
|
evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ui);
|
2019-08-24 07:11:32 -07:00
|
|
|
evas_object_show(win);
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2020-02-15 07:30:31 -08:00
|
|
|
return ui;
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2020-06-18 07:36:39 -07:00
|
|
|
#if defined(DEVELOPMENT)
|
|
|
|
static void
|
2020-10-05 05:19:24 -07:00
|
|
|
_test(int all)
|
2020-06-18 07:36:39 -07:00
|
|
|
{
|
|
|
|
Sys_Info *inf;
|
|
|
|
Eina_List *procs, *disks;
|
|
|
|
Proc_Info *proc;
|
|
|
|
File_System *fs;
|
|
|
|
char *path, *mount;
|
|
|
|
|
|
|
|
printf("Starting testing\n");
|
|
|
|
inf = system_info_all_get();
|
2020-10-08 04:54:33 -07:00
|
|
|
int cpu_count = system_cpu_count_get();
|
|
|
|
for (int i = 0; i < cpu_count; i++)
|
|
|
|
{
|
|
|
|
int temp = system_cpu_n_temperature_get(i);
|
|
|
|
if (temp != -1) printf(" cpu %d temp %d C\n", i, temp);
|
|
|
|
}
|
|
|
|
|
2020-06-18 07:36:39 -07:00
|
|
|
system_info_all_free(inf);
|
|
|
|
|
2020-10-05 05:19:24 -07:00
|
|
|
if (!all) goto out;
|
|
|
|
|
2020-06-18 07:36:39 -07:00
|
|
|
eina_init();
|
|
|
|
ecore_init();
|
|
|
|
|
|
|
|
procs = proc_info_all_get();
|
|
|
|
EINA_LIST_FREE(procs, proc)
|
|
|
|
proc_info_free(proc);
|
|
|
|
|
|
|
|
disks = disks_get();
|
|
|
|
EINA_LIST_FREE(disks, path)
|
|
|
|
{
|
|
|
|
mount = disk_mount_point_get(path);
|
|
|
|
if (mount)
|
|
|
|
{
|
|
|
|
fs = file_system_info_get(mount);
|
|
|
|
if (fs)
|
|
|
|
file_system_info_free(fs);
|
|
|
|
free(mount);
|
|
|
|
}
|
|
|
|
free(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
ecore_shutdown();
|
|
|
|
eina_shutdown();
|
2020-10-05 05:19:24 -07:00
|
|
|
out:
|
|
|
|
printf("Ending testing\n");
|
2020-06-18 07:36:39 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-06-04 03:11:21 -07:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
2020-02-15 07:30:31 -08:00
|
|
|
Ui *ui;
|
2020-05-17 11:30:00 -07:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
{
|
|
|
|
if ((!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "-help")) ||
|
|
|
|
(!strcmp(argv[i], "--help") || !strcasecmp(argv[i], "-v")))
|
|
|
|
{
|
2020-06-18 05:18:53 -07:00
|
|
|
printf("(c) 2018-2020 Alastair Roy Poole <netstar@gmail.com>\n");
|
2020-05-17 11:30:00 -07:00
|
|
|
printf("Evisum version: %s\n", PACKAGE_VERSION);
|
|
|
|
exit(0);
|
|
|
|
}
|
2020-06-18 07:36:39 -07:00
|
|
|
#if defined(DEVELOPMENT)
|
|
|
|
else if (!strcmp(argv[i], "-t"))
|
|
|
|
{
|
2020-10-05 05:19:24 -07:00
|
|
|
_test(1);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
else if (!strcmp(argv[i], "-T"))
|
|
|
|
{
|
|
|
|
_test(0);
|
2020-06-18 07:36:39 -07:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
#endif
|
2020-05-17 11:30:00 -07:00
|
|
|
}
|
2020-02-15 07:30:31 -08:00
|
|
|
|
2018-06-04 03:11:21 -07:00
|
|
|
eina_init();
|
|
|
|
ecore_init();
|
2020-04-14 10:24:27 -07:00
|
|
|
config_init();
|
2018-06-04 03:11:21 -07:00
|
|
|
elm_init(argc, argv);
|
|
|
|
|
2020-04-23 04:28:07 -07:00
|
|
|
#if ENABLE_NLS
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
|
bind_textdomain_codeset(PACKAGE, "UTF-8");
|
|
|
|
textdomain(PACKAGE);
|
|
|
|
#endif
|
|
|
|
|
2020-02-15 07:30:31 -08:00
|
|
|
ui = _win_add();
|
|
|
|
if (ui)
|
|
|
|
{
|
|
|
|
ecore_main_loop_begin();
|
2020-06-30 05:05:35 -07:00
|
|
|
evisum_ui_del(ui);
|
2020-02-15 07:30:31 -08:00
|
|
|
}
|
2018-06-04 03:11:21 -07:00
|
|
|
|
|
|
|
elm_shutdown();
|
2020-04-14 10:24:27 -07:00
|
|
|
config_shutdown();
|
2018-06-16 07:09:10 -07:00
|
|
|
ecore_shutdown();
|
|
|
|
eina_shutdown();
|
2018-06-04 03:11:21 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|