0.5: Update to reflect 0.5.5 changes.
9
CREDITS
|
@ -1,3 +1,8 @@
|
|||
# Artwork
|
||||
|
||||
Beautiful background images of the sky by rasterman.
|
||||
In the public domain.
|
||||
|
||||
# About Evisum (Imagery)
|
||||
|
||||
Lichfield Cathedral - West Midlands Constabulary.
|
||||
|
@ -13,6 +18,10 @@ from the original by the software author.
|
|||
|
||||
# Thanks
|
||||
|
||||
To our dedicated users in '#e'.
|
||||
|
||||
Especially OnlyHuman, thrice, Peter2121, ApBBB...
|
||||
|
||||
Philippe Jean Guillaumie <similar@orange.fr>
|
||||
|
||||
For his relentless commitment to translation of EFL and
|
||||
|
|
39
NEWS
|
@ -1,3 +1,42 @@
|
|||
============
|
||||
Evisum 0.5.5
|
||||
============
|
||||
|
||||
* Added CPU frequency scaling support.
|
||||
* Show kernel threads by default.
|
||||
* Add configurable poll time (see new menu).
|
||||
* CPU / Mem view respect polling settings.
|
||||
* Improve genlist behaviours.
|
||||
* Replaced the elm_menu with a better menu.
|
||||
* New per-core CPU window (thanks raster).
|
||||
* Some icons from bling (thanks raster).
|
||||
* Some photographs of skies (thanks raster).
|
||||
* Some animation, images and icons.
|
||||
* Add a mascot (Harvey my Australian dog).
|
||||
* Fix rare crash.
|
||||
* UI changes...
|
||||
* Other small fixes undocumented.
|
||||
* No more macOS features or changes as they are locking
|
||||
down their eco-system...things change all the time with
|
||||
zero documentation and to access various OS sub-systems
|
||||
you are required signing certicates and your name in blood...
|
||||
|
||||
Not really a fan of Darwinisms, more into string theory...
|
||||
|
||||
============
|
||||
Evisum 0.5.4
|
||||
============
|
||||
|
||||
* Fix typo (Linux battery).
|
||||
|
||||
============
|
||||
Evisum 0.5.3
|
||||
============
|
||||
|
||||
* Option to show kernel threads.
|
||||
* Show PPID in process view.
|
||||
* Show process start time.
|
||||
|
||||
============
|
||||
Evisum 0.5.2
|
||||
============
|
||||
|
|
10
README
|
@ -3,7 +3,7 @@
|
|||
System Monitor (EFL)
|
||||
|
||||
This is a process monitor and system monitor for Linux, OpenBSD,
|
||||
FreeBSD, DragonFlyBSD and macOS.
|
||||
FreeBSD and DragonFlyBSD.
|
||||
|
||||
REQUIREMENTS:
|
||||
|
||||
|
@ -27,5 +27,9 @@ CONTRIBUTIONS:
|
|||
|
||||
Patches with bug fixes are more than welcome. If you do wish to
|
||||
add a substantial querying feature PLEASE ensure that it works reliaibly
|
||||
on OpenBSD, Linux and FreeBSD (ideally macOS also). UI changes
|
||||
should be platform independent.
|
||||
on OpenBSD, Linux and FreeBSD.
|
||||
|
||||
NOTES:
|
||||
|
||||
Ctrl + k or Ctrl + K to show/hide kernel threads.
|
||||
Ctrl + e or Ctrl + E to show/hide evisum in the process list.
|
||||
|
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 465 KiB |
After Width: | Height: | Size: 2.1 MiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 576 B After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 733 KiB After Width: | Height: | Size: 648 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 769 B |
|
@ -4,5 +4,10 @@ install_data('go-up.png', 'go-down.png',
|
|||
'kill.png', 'cancel.png',
|
||||
'increase.png', 'decrease.png',
|
||||
'sensor.png', 'mount.png', 'ladyhand.png',
|
||||
'find.png', 'bug.png', 'exit.png',
|
||||
'find.png', 'bug.png', 'exit.png', 'cpu.png',
|
||||
'memory.png', 'storage.png', 'misc.png',
|
||||
'sky_01.jpg', 'sky_02.jpg', 'sky_03.jpg',
|
||||
'sky_04.jpg', 'effects.png',
|
||||
'clo.png', 'bolt.png', 'menu.png',
|
||||
'lovethisdogharvey.png',
|
||||
install_dir: join_paths(dir_data, 'evisum/images'))
|
||||
|
|
After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 455 KiB |
After Width: | Height: | Size: 472 KiB |
After Width: | Height: | Size: 828 KiB |
After Width: | Height: | Size: 1.5 MiB |
After Width: | Height: | Size: 14 KiB |
|
@ -1,6 +1,6 @@
|
|||
##### Project
|
||||
project('evisum', 'c',
|
||||
version : '0.5.2',
|
||||
version : '0.5.5',
|
||||
meson_version : '>= 0.40.0')
|
||||
|
||||
efl_version = '>= 1.22.0'
|
||||
|
|
|
@ -29,6 +29,33 @@ config_shutdown(void)
|
|||
efreet_shutdown();
|
||||
}
|
||||
|
||||
static void
|
||||
_config_fail(const char *msg)
|
||||
{
|
||||
fprintf(stderr, "ERR: config %s.\n", msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
_config_check(Evisum_Config *cfg)
|
||||
{
|
||||
if (cfg->version > CONFIG_VERSION)
|
||||
_config_fail("version");
|
||||
|
||||
if (cfg->poll_delay <= 0)
|
||||
_config_fail("poll");
|
||||
}
|
||||
|
||||
static Evisum_Config *
|
||||
_config_init()
|
||||
{
|
||||
Evisum_Config *cfg = calloc(1, sizeof(Evisum_Config));
|
||||
cfg->version = CONFIG_VERSION;
|
||||
cfg->poll_delay = 3;
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
Evisum_Config *
|
||||
config_load(void)
|
||||
{
|
||||
|
@ -39,17 +66,28 @@ config_load(void)
|
|||
const char *path = _config_file_path();
|
||||
if (!ecore_file_exists(path))
|
||||
{
|
||||
cfg = calloc(1, sizeof(Evisum_Config));
|
||||
cfg->version = CONFIG_VERSION;
|
||||
cfg = _config_init();
|
||||
|
||||
f = eet_open(path, EET_FILE_MODE_WRITE);
|
||||
if (!f) _config_fail("create");
|
||||
eet_write(f, "Config", cfg, sizeof(Evisum_Config), 0);
|
||||
eet_close(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
f = eet_open(path, EET_FILE_MODE_READ);
|
||||
if (!f) exit(127);
|
||||
if (!f) _config_fail("read");
|
||||
cfg = eet_read(f, "Config", &size);
|
||||
|
||||
if (cfg->version < CONFIG_VERSION)
|
||||
{
|
||||
free(cfg);
|
||||
fprintf(stderr, "INFO: Reinitialising configuration\n");
|
||||
|
||||
cfg = _config_init();
|
||||
}
|
||||
_config_check(cfg);
|
||||
|
||||
eet_close(f);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "ui/ui.h"
|
||||
|
||||
#define CONFIG_VERSION 0x0002
|
||||
#define CONFIG_VERSION 0x0005
|
||||
|
||||
typedef struct _Evisum_Config
|
||||
{
|
||||
|
@ -12,6 +12,8 @@ typedef struct _Evisum_Config
|
|||
Eina_Bool sort_reverse;
|
||||
int width;
|
||||
int height;
|
||||
int poll_delay;
|
||||
Eina_Bool effects;
|
||||
} Evisum_Config;
|
||||
|
||||
void config_init(void);
|
||||
|
|
|
@ -97,6 +97,15 @@ system_cpu_usage_get(int *ncpu);
|
|||
cpu_core_t **
|
||||
system_cpu_usage_delayed_get(int *ncpu, int usecs);
|
||||
|
||||
int
|
||||
system_cpu_frequency_get(void);
|
||||
|
||||
int
|
||||
system_cpu_n_frequency_get(int n);
|
||||
|
||||
int
|
||||
system_cpu_frequency_min_max_get(int *min, int *max);
|
||||
|
||||
void
|
||||
system_memory_usage_get(meminfo_t *memory);
|
||||
|
||||
|
|
|
@ -279,3 +279,164 @@ system_cpu_usage_get(int *ncpu)
|
|||
return system_cpu_usage_delayed_get(ncpu, 1000000);
|
||||
}
|
||||
|
||||
int
|
||||
system_cpu_n_frequency_get(int n)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
int freq = -1;
|
||||
FILE *f;
|
||||
char buf[4096];
|
||||
int tmp;
|
||||
|
||||
snprintf(buf, sizeof(buf), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", n);
|
||||
f = fopen(buf, "r");
|
||||
if (f)
|
||||
{
|
||||
if (fgets(buf, sizeof(buf), f))
|
||||
{
|
||||
tmp = strtol(buf, NULL, 10);
|
||||
if (!((tmp == LONG_MIN || tmp == LONG_MAX) && errno == ERANGE))
|
||||
freq = tmp;
|
||||
}
|
||||
fclose(f);
|
||||
if (freq != -1) return freq;
|
||||
}
|
||||
|
||||
return freq;
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
|
||||
return system_cpu_frequency_get();
|
||||
#endif
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
system_cpu_frequency_min_max_get(int *min, int *max)
|
||||
{
|
||||
int freq_min = 0x7fffffff, freq_max = 0;
|
||||
#if defined(__linux__)
|
||||
char *s;
|
||||
|
||||
s = file_contents("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq");
|
||||
if (s)
|
||||
{
|
||||
freq_min = atoi(s);
|
||||
free(s);
|
||||
s = file_contents("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq");
|
||||
if (s)
|
||||
{
|
||||
freq_max = atoi(s);
|
||||
free(s);
|
||||
*min = freq_min;
|
||||
*max = freq_max;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
s = file_contents("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies");
|
||||
if (!s) return -1;
|
||||
|
||||
char *t = strtok(s, " ");
|
||||
while (t)
|
||||
{
|
||||
int freq = atoi(t);
|
||||
if (freq > freq_max) freq_max = freq;
|
||||
if (freq < freq_min) freq_min = freq;
|
||||
t = strtok(NULL, " ");
|
||||
}
|
||||
|
||||
free(s);
|
||||
|
||||
if (freq_min == 0x7fffffff || freq_max == 0) return -1;
|
||||
|
||||
*min = freq_min;
|
||||
*max = freq_max;
|
||||
|
||||
return 0;
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
char buf[4096];
|
||||
size_t len = sizeof(buf);
|
||||
char *t, *s;
|
||||
|
||||
if (sysctlbyname("dev.cpu.0.freq_levels", buf, &len, NULL, 0) != -1)
|
||||
{
|
||||
s = buf;
|
||||
while (s)
|
||||
{
|
||||
t = strchr(s, '/');
|
||||
if (!t) break;
|
||||
*t = '\0';
|
||||
int freq = atoi(s) * 1000;
|
||||
if (freq > freq_max) freq_max = freq;
|
||||
if (freq < freq_min) freq_min = freq;
|
||||
|
||||
s = strchr(t + 1, ' ');
|
||||
}
|
||||
if (freq_min == 0x7fffffff || freq_max == 0) return -1;
|
||||
|
||||
*min = freq_min;
|
||||
*max = freq_max;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(__OpenBSD__)
|
||||
|
||||
#endif
|
||||
(void) freq_min; (void) freq_max;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
system_cpu_frequency_get(void)
|
||||
{
|
||||
int freq = -1;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
size_t len = sizeof(freq);
|
||||
if (sysctlbyname("dev.cpu.0.freq", &freq, &len, NULL, 0) != -1)
|
||||
freq *= 1000;
|
||||
#elif defined(__OpenBSD__)
|
||||
int mib[2] = { CTL_HW, HW_CPUSPEED };
|
||||
size_t len = sizeof(freq);
|
||||
if (sysctl(mib, sizeof(mib), &freq, &len, NULL, 0) != -1)
|
||||
freq *= 1000;
|
||||
#elif defined(__linux__)
|
||||
FILE *f;
|
||||
char buf[4096];
|
||||
int tmp;
|
||||
|
||||
f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", "r");
|
||||
if (f)
|
||||
{
|
||||
if (fgets(buf, sizeof(buf), f))
|
||||
{
|
||||
tmp = strtol(buf, NULL, 10);
|
||||
if (!((tmp == LONG_MIN || tmp == LONG_MAX) && errno == ERANGE))
|
||||
freq = tmp;
|
||||
}
|
||||
fclose(f);
|
||||
if (freq != -1) return freq;
|
||||
}
|
||||
|
||||
f = fopen("/proc/cpuinfo", "r");
|
||||
if (!f) return freq;
|
||||
|
||||
while (fgets(buf, sizeof(buf), f))
|
||||
{
|
||||
if (!strncasecmp(buf, "cpu MHz", 7))
|
||||
{
|
||||
char *s = strchr(buf, ':') + 1;
|
||||
tmp = strtol(s, NULL, 10);
|
||||
if (!((tmp == LONG_MIN || tmp == LONG_MAX) && errno == ERANGE))
|
||||
freq = tmp * 1000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
#else
|
||||
|
||||
#endif
|
||||
return freq;
|
||||
}
|
||||
|
|
|
@ -282,7 +282,7 @@ _battery_state_get(power_t *power)
|
|||
for (int i = 0; i < power->battery_count; i++) {
|
||||
naming = NULL;
|
||||
|
||||
path = strsli_printf("/sys/class/power_suppy/%s", power->batteries[i]->name);
|
||||
path = strsli_printf("/sys/class/power_supply/%s", power->batteries[i]->name);
|
||||
|
||||
if (((stat(path, &st) < 0)) || (S_ISLNK(st.st_mode)) || (!S_ISDIR(st.st_mode)))
|
||||
continue;
|
||||
|
|
|
@ -44,6 +44,20 @@
|
|||
|
||||
#include "macros.h"
|
||||
|
||||
static Eina_Bool _show_kthreads = EINA_TRUE;
|
||||
|
||||
void
|
||||
proc_info_kthreads_show_set(Eina_Bool enabled)
|
||||
{
|
||||
_show_kthreads = enabled;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
proc_info_kthreads_show_get(void)
|
||||
{
|
||||
return _show_kthreads;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_process_state_name(char state)
|
||||
{
|
||||
|
@ -240,9 +254,33 @@ _uid(int pid)
|
|||
return uid;
|
||||
}
|
||||
|
||||
static int64_t
|
||||
_boot_time(void)
|
||||
{
|
||||
FILE *f;
|
||||
int64_t boot_time;
|
||||
char buf[4096];
|
||||
double uptime = 0.0;
|
||||
|
||||
f = fopen("/proc/uptime", "r");
|
||||
if (!f) return 0;
|
||||
|
||||
if (fgets(buf, sizeof(buf), f))
|
||||
sscanf(buf, "%lf", &uptime);
|
||||
else boot_time = 0;
|
||||
|
||||
fclose(f);
|
||||
|
||||
if (uptime > 0.0)
|
||||
boot_time = time(NULL) - (time_t) uptime;
|
||||
|
||||
return boot_time;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int pid, utime, stime, cutime, cstime;
|
||||
int pid, ppid, utime, stime, cutime, cstime;
|
||||
int psr, pri, nice, numthreads;
|
||||
long long int start_time;
|
||||
char state;
|
||||
unsigned int mem_rss, flags;
|
||||
unsigned long mem_virt;
|
||||
|
@ -255,6 +293,9 @@ _stat(const char *path, Stat *st)
|
|||
FILE *f;
|
||||
char line[4096];
|
||||
int dummy, res = 0;
|
||||
static int64_t boot_time = 0;
|
||||
|
||||
if (!boot_time) boot_time = _boot_time();
|
||||
|
||||
memset(st, 0, sizeof(Stat));
|
||||
|
||||
|
@ -269,11 +310,11 @@ _stat(const char *path, Stat *st)
|
|||
strncpy(st->name, start, end - start);
|
||||
st->name[end - start] = '\0';
|
||||
res = sscanf(end + 2, "%c %d %d %d %d %d %u %u %u %u %u %d %d %d"
|
||||
" %d %d %d %u %u %d %lu %u %u %u %u %u %u %u %d %d %d %d %u"
|
||||
" %d %d %d %u %u %lld %lu %u %u %u %u %u %u %u %d %d %d %d %u"
|
||||
" %d %d %d %d %d %d %d %d %d",
|
||||
&st->state, &dummy, &dummy, &dummy, &dummy, &dummy, &st->flags,
|
||||
&st->state, &st->ppid, &dummy, &dummy, &dummy, &dummy, &st->flags,
|
||||
&dummy, &dummy, &dummy, &dummy, &st->utime, &st->stime, &st->cutime,
|
||||
&st->cstime, &st->pri, &st->nice, &st->numthreads, &dummy, &dummy,
|
||||
&st->cstime, &st->pri, &st->nice, &st->numthreads, &dummy, &st->start_time,
|
||||
&st->mem_virt, &st->mem_rss, &dummy, &dummy, &dummy, &dummy, &dummy,
|
||||
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy,
|
||||
&dummy, &dummy, &st->psr, &dummy, &dummy, &dummy, &dummy, &dummy);
|
||||
|
@ -282,6 +323,9 @@ _stat(const char *path, Stat *st)
|
|||
|
||||
if (res != 42) return EINA_FALSE;
|
||||
|
||||
st->start_time /= sysconf(_SC_CLK_TCK);
|
||||
st->start_time += boot_time;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
@ -305,14 +349,17 @@ _process_list_linux_get(void)
|
|||
if (!_stat(eina_slstr_printf("/proc/%d/stat", pid), &st))
|
||||
continue;
|
||||
|
||||
if (st.flags & PF_KTHREAD) continue;
|
||||
if (st.flags & PF_KTHREAD && !proc_info_kthreads_show_get())
|
||||
continue;
|
||||
|
||||
Proc_Info *p = calloc(1, sizeof(Proc_Info));
|
||||
if (!p) return NULL;
|
||||
|
||||
p->pid = pid;
|
||||
p->ppid = st.ppid;
|
||||
p->uid = _uid(pid);
|
||||
p->cpu_id = st.psr;
|
||||
p->start = st.start_time;
|
||||
p->state = _process_state_name(st.state);
|
||||
p->cpu_time = st.utime + st.stime;
|
||||
p->nice = st.nice;
|
||||
|
@ -372,8 +419,10 @@ proc_info_by_pid(int pid)
|
|||
if (!p) return NULL;
|
||||
|
||||
p->pid = pid;
|
||||
p->ppid = st.ppid;
|
||||
p->uid = _uid(pid);
|
||||
p->cpu_id = st.psr;
|
||||
p->start = st.start_time;
|
||||
p->state = _process_state_name(st.state);
|
||||
p->cpu_time = st.utime + st.stime;
|
||||
p->priority = st.pri;
|
||||
|
@ -399,8 +448,10 @@ _proc_get(Proc_Info *p, struct kinfo_proc *kp)
|
|||
if (!pagesize) pagesize = getpagesize();
|
||||
|
||||
p->pid = kp->p_pid;
|
||||
p->ppid = kp->p_ppid;
|
||||
p->uid = kp->p_uid;
|
||||
p->cpu_id = kp->p_cpuid;
|
||||
p->start = kp->p_ustart_sec;
|
||||
p->state = _process_state_name(kp->p_stat);
|
||||
p->cpu_time = kp->p_uticks + kp->p_sticks + kp->p_iticks;
|
||||
p->mem_virt = p->mem_size = (MEMSZ(kp->p_vm_tsize) * MEMSZ(pagesize)) +
|
||||
|
@ -657,11 +708,13 @@ _proc_pidinfo(size_t pid)
|
|||
if (!p) return NULL;
|
||||
|
||||
p->pid = pid;
|
||||
p->ppid = taskinfo.pbsd.pbi_ppid;
|
||||
p->uid = taskinfo.pbsd.pbi_uid;
|
||||
p->cpu_id = -1;
|
||||
p->cpu_time = taskinfo.ptinfo.pti_total_user +
|
||||
taskinfo.ptinfo.pti_total_system;
|
||||
p->cpu_time /= 10000000;
|
||||
p->start = taskinfo.pbsd.pbi_start_tvsec;
|
||||
p->state = _process_state_name(taskinfo.pbsd.pbi_status);
|
||||
p->mem_size = p->mem_virt = taskinfo.ptinfo.pti_virtual_size;
|
||||
p->mem_rss = taskinfo.ptinfo.pti_resident_size;
|
||||
|
@ -743,10 +796,12 @@ proc_info_by_pid(int pid)
|
|||
|
||||
p->pid = pid;
|
||||
p->uid = taskinfo.pbsd.pbi_uid;
|
||||
p->ppid = taskinfo.pbsd.pbi_ppid;
|
||||
p->cpu_id = workqueue.pwq_nthreads;
|
||||
p->cpu_time = taskinfo.ptinfo.pti_total_user +
|
||||
taskinfo.ptinfo.pti_total_system;
|
||||
p->cpu_time /= 10000000;
|
||||
p->start = taskinfo.pbsd.pbi_start_tvsec;
|
||||
p->state = _process_state_name(taskinfo.pbsd.pbi_status);
|
||||
p->mem_size = p->mem_virt = taskinfo.ptinfo.pti_virtual_size;
|
||||
p->mem_rss = taskinfo.ptinfo.pti_resident_size;
|
||||
|
@ -843,6 +898,7 @@ _proc_thread_info(struct kinfo_proc *kp, Eina_Bool is_thread)
|
|||
if (!p) return NULL;
|
||||
|
||||
p->pid = kp->ki_pid;
|
||||
p->ppid = kp->ki_ppid;
|
||||
p->uid = kp->ki_uid;
|
||||
|
||||
if (!is_thread)
|
||||
|
@ -856,10 +912,12 @@ _proc_thread_info(struct kinfo_proc *kp, Eina_Bool is_thread)
|
|||
|
||||
p->cpu_time = (usage->ru_utime.tv_sec * 1000000) + usage->ru_utime.tv_usec +
|
||||
(usage->ru_stime.tv_sec * 1000000) + usage->ru_stime.tv_usec;
|
||||
// XXX: See kern.sched.idlespins
|
||||
p->cpu_time /= 10000;
|
||||
p->state = _process_state_name(kp->ki_stat);
|
||||
p->mem_virt = kp->ki_size;
|
||||
p->mem_rss = MEMSZ(kp->ki_rssize) * MEMSZ(pagesize);
|
||||
p->start = kp->ki_start.tv_sec;
|
||||
p->mem_size = p->mem_virt;
|
||||
p->nice = kp->ki_nice - NZERO;
|
||||
p->priority = kp->ki_pri.pri_level - PZERO;
|
||||
|
@ -895,7 +953,7 @@ _process_list_freebsd_fallback_get(void)
|
|||
if (sysctl(mib, 4, &kp, &len, NULL, 0) == -1)
|
||||
continue;
|
||||
|
||||
if (kp.ki_flag & P_KPROC)
|
||||
if (kp.ki_flag & P_KPROC && !proc_info_kthreads_show_get())
|
||||
continue;
|
||||
|
||||
Proc_Info *p = _proc_thread_info(&kp, EINA_FALSE);
|
||||
|
@ -928,7 +986,7 @@ _process_list_freebsd_get(void)
|
|||
|
||||
for (int i = 0; i < pid_count; i++)
|
||||
{
|
||||
if (kps[i].ki_flag & P_KPROC)
|
||||
if (kps[i].ki_flag & P_KPROC && !proc_info_kthreads_show_get())
|
||||
continue;
|
||||
|
||||
kp = &kps[i];
|
||||
|
@ -988,7 +1046,7 @@ proc_info_by_pid(int pid)
|
|||
|
||||
for (int i = 0; i < pid_count; i++)
|
||||
{
|
||||
if (kps[i].ki_flag & P_KPROC)
|
||||
if (kps[i].ki_flag & P_KPROC && !proc_info_kthreads_show_get())
|
||||
continue;
|
||||
if (kps[i].ki_pid != pid)
|
||||
continue;
|
||||
|
|
|
@ -27,13 +27,15 @@
|
|||
typedef struct _Proc_Info
|
||||
{
|
||||
pid_t pid;
|
||||
pid_t ppid;
|
||||
uid_t uid;
|
||||
int8_t nice;
|
||||
int8_t priority;
|
||||
int cpu_id;
|
||||
int32_t numthreads;
|
||||
long cpu_time;
|
||||
int64_t cpu_time;
|
||||
double cpu_usage;
|
||||
int64_t start;
|
||||
|
||||
uint64_t mem_size;
|
||||
uint64_t mem_virt;
|
||||
|
@ -76,6 +78,23 @@ proc_info_by_pid(int pid);
|
|||
void
|
||||
proc_info_free(Proc_Info *proc);
|
||||
|
||||
|
||||
/**
|
||||
* Enable or disable the listing of kernel threads.
|
||||
*
|
||||
* @param enabled Boolean true or false (show/hide).
|
||||
*/
|
||||
void
|
||||
proc_info_kthreads_show_set(Eina_Bool enabled);
|
||||
|
||||
/**
|
||||
* Return the current policy for listing kernel threads.
|
||||
*
|
||||
* @return True or false (enabled/disabled).
|
||||
*/
|
||||
Eina_Bool
|
||||
proc_info_kthreads_show_get(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
581
src/bin/ui/ui.c
|
@ -11,6 +11,8 @@
|
|||
#include <sys/resource.h>
|
||||
#include <pwd.h>
|
||||
|
||||
// These should be static. Please do not change.
|
||||
// OpenBSD has issues which are undetermined yet.
|
||||
Ui *_ui;
|
||||
Evisum_Config *_evisum_config;
|
||||
static Eina_Lock _lock;
|
||||
|
@ -28,6 +30,8 @@ _config_save(Ui *ui)
|
|||
_evisum_config->sort_reverse = ui->sort_reverse;
|
||||
_evisum_config->width = w;
|
||||
_evisum_config->height = h;
|
||||
_evisum_config->effects = evisum_ui_effects_enabled_get();
|
||||
_evisum_config->poll_delay = ui->poll_delay;
|
||||
|
||||
config_save(_evisum_config);
|
||||
}
|
||||
|
@ -39,9 +43,12 @@ _config_load(Ui *ui)
|
|||
|
||||
ui->sort_type = _evisum_config->sort_type;
|
||||
ui->sort_reverse = _evisum_config->sort_reverse;
|
||||
ui->poll_delay = _evisum_config->poll_delay;
|
||||
|
||||
if ((_evisum_config->width > 0) && (_evisum_config->height > 0))
|
||||
evas_object_resize(ui->win, _evisum_config->width, _evisum_config->height);
|
||||
|
||||
evisum_ui_effects_enabled_set(_evisum_config->effects);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -253,6 +260,15 @@ _proc_pid_cpu_times_free(Ui *ui)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_proc_pid_cpu_times_reset(Ui *ui)
|
||||
{
|
||||
Eina_List *l;
|
||||
pid_cpu_time_t *tmp;
|
||||
EINA_LIST_FOREACH(ui->cpu_times, l, tmp)
|
||||
tmp->cpu_time_prev = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_proc_pid_cpu_time_save(Ui *ui, Proc_Info *proc)
|
||||
{
|
||||
|
@ -357,9 +373,9 @@ _item_create(Evas_Object *parent)
|
|||
table = elm_table_add(obj);
|
||||
evas_object_size_hint_align_set(table, EXPAND, EXPAND);
|
||||
evas_object_size_hint_weight_set(table, FILL, FILL);
|
||||
evas_object_show(table);
|
||||
|
||||
_item_column_add(table, "proc_pid", 0);
|
||||
label = _item_column_add(table, "proc_pid", 0);
|
||||
evas_object_size_hint_align_set(label, 1.0, EXPAND);
|
||||
_item_column_add(table, "proc_uid", 1);
|
||||
_item_column_add(table, "proc_size", 2);
|
||||
_item_column_add(table, "proc_rss", 3);
|
||||
|
@ -374,15 +390,6 @@ _item_create(Evas_Object *parent)
|
|||
return table;
|
||||
}
|
||||
|
||||
static void
|
||||
_item_show_hide(Evas_Object *obj, Eina_Bool show)
|
||||
{
|
||||
if (show)
|
||||
evas_object_show(obj);
|
||||
else
|
||||
evas_object_hide(obj);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_content_get(void *data, Evas_Object *obj, const char *source)
|
||||
{
|
||||
|
@ -413,7 +420,7 @@ _content_get(void *data, Evas_Object *obj, const char *source)
|
|||
if (ow > w) evas_object_size_hint_min_set(ui->btn_pid, w, 1);
|
||||
r = evas_object_data_get(l, "rect");
|
||||
evas_object_size_hint_min_set(r, w, 1);
|
||||
_item_show_hide(l, ui->show_genlist);
|
||||
evas_object_show(l);
|
||||
|
||||
evas_object_geometry_get(ui->btn_uid, NULL, NULL, &w, NULL);
|
||||
l = evas_object_data_get(it->obj, "proc_uid");
|
||||
|
@ -426,7 +433,7 @@ _content_get(void *data, Evas_Object *obj, const char *source)
|
|||
if (ow > w) evas_object_size_hint_min_set(ui->btn_uid, w, 1);
|
||||
r = evas_object_data_get(l, "rect");
|
||||
evas_object_size_hint_min_set(r, w, 1);
|
||||
_item_show_hide(l, ui->show_genlist);
|
||||
evas_object_show(l);
|
||||
|
||||
evas_object_geometry_get(ui->btn_size, NULL, NULL, &w, NULL);
|
||||
l = evas_object_data_get(it->obj, "proc_size");
|
||||
|
@ -435,7 +442,7 @@ _content_get(void *data, Evas_Object *obj, const char *source)
|
|||
if (ow > w) evas_object_size_hint_min_set(ui->btn_size, w, 1);
|
||||
r = evas_object_data_get(l, "rect");
|
||||
evas_object_size_hint_min_set(r, w, 1);
|
||||
_item_show_hide(l, ui->show_genlist);
|
||||
evas_object_show(l);
|
||||
|
||||
evas_object_geometry_get(ui->btn_rss, NULL, NULL, &w, NULL);
|
||||
l = evas_object_data_get(it->obj, "proc_rss");
|
||||
|
@ -444,7 +451,7 @@ _content_get(void *data, Evas_Object *obj, const char *source)
|
|||
if (ow > w) evas_object_size_hint_min_set(ui->btn_rss, w, 1);
|
||||
r = evas_object_data_get(l, "rect");
|
||||
evas_object_size_hint_min_set(r, w, 1);
|
||||
_item_show_hide(l, ui->show_genlist);
|
||||
evas_object_show(l);
|
||||
|
||||
evas_object_geometry_get(ui->btn_cmd, NULL, NULL, &w, NULL);
|
||||
l = evas_object_data_get(it->obj, "proc_cmd");
|
||||
|
@ -453,7 +460,7 @@ _content_get(void *data, Evas_Object *obj, const char *source)
|
|||
if (ow > w) evas_object_size_hint_min_set(ui->btn_cmd, w, 1);
|
||||
r = evas_object_data_get(l, "rect");
|
||||
evas_object_size_hint_min_set(r, w, 1);
|
||||
_item_show_hide(l, ui->show_genlist);
|
||||
evas_object_show(l);
|
||||
|
||||
evas_object_geometry_get(ui->btn_state, NULL, NULL, &w, NULL);
|
||||
l = evas_object_data_get(it->obj, "proc_state");
|
||||
|
@ -462,16 +469,20 @@ _content_get(void *data, Evas_Object *obj, const char *source)
|
|||
if (ow > w) evas_object_size_hint_min_set(ui->btn_state, w, 1);
|
||||
r = evas_object_data_get(l, "rect");
|
||||
evas_object_size_hint_min_set(r, w, 1);
|
||||
_item_show_hide(l, ui->show_genlist);
|
||||
evas_object_show(l);
|
||||
|
||||
evas_object_geometry_get(ui->btn_cpu_usage, NULL, NULL, &w, NULL);
|
||||
l = evas_object_data_get(it->obj, "proc_cpu_usage");
|
||||
elm_object_text_set(l, eina_slstr_printf("%.1f%%", proc->cpu_usage));
|
||||
elm_object_text_set(l, eina_slstr_printf("%.1f %%", proc->cpu_usage));
|
||||
evas_object_geometry_get(l, NULL, NULL, &ow, NULL);
|
||||
if (ow > w) evas_object_size_hint_min_set(ui->btn_cpu_usage, w, 1);
|
||||
r = evas_object_data_get(l, "rect");
|
||||
evas_object_size_hint_min_set(r, w, 1);
|
||||
_item_show_hide(l, ui->show_genlist);
|
||||
evas_object_show(l);
|
||||
|
||||
evas_object_show(it->obj);
|
||||
// Let the genlist resize but align the text.
|
||||
elm_table_align_set(it->obj, 0, 0.5);
|
||||
|
||||
return it->obj;
|
||||
}
|
||||
|
@ -515,8 +526,9 @@ static Eina_Bool
|
|||
_show_items(void *data)
|
||||
{
|
||||
Ui *ui = data;
|
||||
ui->show_genlist = EINA_TRUE;
|
||||
|
||||
elm_genlist_realized_items_update(ui->genlist_procs);
|
||||
evas_object_show(ui->genlist_procs);
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
@ -549,7 +561,8 @@ _process_list_feedback_cb(void *data, Ecore_Thread *thread EINA_UNUSED,
|
|||
|
||||
ui = data;
|
||||
|
||||
eina_lock_take(&_lock);
|
||||
if (!eina_lock_take_try(&_lock))
|
||||
return;
|
||||
|
||||
list = proc_info_all_get();
|
||||
|
||||
|
@ -573,20 +586,29 @@ _process_list_feedback_cb(void *data, Ecore_Thread *thread EINA_UNUSED,
|
|||
}
|
||||
|
||||
_genlist_ensure_n_items(ui->genlist_procs, eina_list_count(list));
|
||||
|
||||
it = elm_genlist_first_item_get(ui->genlist_procs);
|
||||
|
||||
list = _list_sort(ui, list);
|
||||
|
||||
EINA_LIST_FREE(list, proc)
|
||||
{
|
||||
Proc_Info *prev = elm_object_item_data_get(it);
|
||||
if (prev)
|
||||
proc_info_free(prev);
|
||||
if (!it)
|
||||
proc_info_free(proc);
|
||||
else
|
||||
{
|
||||
Proc_Info *prev = elm_object_item_data_get(it);
|
||||
if (prev)
|
||||
proc_info_free(prev);
|
||||
|
||||
elm_object_item_data_set(it, proc);
|
||||
elm_genlist_item_update(it);
|
||||
it = elm_genlist_item_next_get(it);
|
||||
elm_object_item_data_set(it, proc);
|
||||
|
||||
it = elm_genlist_item_next_get(it);
|
||||
}
|
||||
}
|
||||
|
||||
elm_genlist_realized_items_update(ui->genlist_procs);
|
||||
|
||||
eina_lock_release(&_lock);
|
||||
}
|
||||
|
||||
|
@ -631,7 +653,7 @@ _btn_icon_state_update(Evas_Object *button, Eina_Bool reverse)
|
|||
Evas_Object *icon = elm_icon_add(button);
|
||||
|
||||
if (_selected)
|
||||
evas_object_color_set(_selected, 47, 153, 255, 255);
|
||||
evas_object_color_set(_selected, 255, 255, 255, 255);
|
||||
|
||||
if (reverse)
|
||||
elm_icon_standard_set(icon, evisum_icon_path_get("go-down"));
|
||||
|
@ -639,7 +661,7 @@ _btn_icon_state_update(Evas_Object *button, Eina_Bool reverse)
|
|||
elm_icon_standard_set(icon, evisum_icon_path_get("go-up"));
|
||||
|
||||
_selected = icon;
|
||||
evas_object_color_set(_selected, 228, 228, 228, 255);
|
||||
evas_object_color_set(_selected, 255, 255, 255, 255);
|
||||
|
||||
elm_object_part_content_set(button, "icon", icon);
|
||||
evas_object_show(icon);
|
||||
|
@ -656,11 +678,11 @@ _btn_icon_state_init(Evas_Object *button, Eina_Bool reverse, Eina_Bool selected)
|
|||
elm_icon_standard_set(icon, evisum_icon_path_get("go-up"));
|
||||
|
||||
if (!selected)
|
||||
evas_object_color_set(icon, 47, 153, 255, 255);
|
||||
evas_object_color_set(icon, 255, 255, 255, 255);
|
||||
else
|
||||
{
|
||||
_selected = icon;
|
||||
evas_object_color_set(icon, 228, 228, 228, 255);
|
||||
evas_object_color_set(icon, 255, 255, 255, 255);
|
||||
}
|
||||
|
||||
elm_object_part_content_set(button, "icon", icon);
|
||||
|
@ -769,16 +791,6 @@ _btn_state_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
_btn_clicked_state_save(ui, ui->btn_state);
|
||||
}
|
||||
|
||||
static void
|
||||
_quit_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
ui->shutdown_now = EINA_TRUE;
|
||||
evisum_ui_shutdown(ui);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_menu_dismissed_cb(void *data EINA_UNUSED, Evas_Object *obj,
|
||||
void *ev EINA_UNUSED)
|
||||
|
@ -796,8 +808,6 @@ _item_menu_start_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
{
|
||||
Ui *ui = data;
|
||||
|
||||
if (!ui) return;
|
||||
|
||||
kill(ui->selected_pid, SIGCONT);
|
||||
}
|
||||
|
||||
|
@ -807,8 +817,6 @@ _item_menu_stop_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
{
|
||||
Ui *ui = data;
|
||||
|
||||
if (!ui) return;
|
||||
|
||||
kill(ui->selected_pid, SIGSTOP);
|
||||
}
|
||||
|
||||
|
@ -818,8 +826,6 @@ _item_menu_kill_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
{
|
||||
Ui *ui = data;
|
||||
|
||||
if (!ui) return;
|
||||
|
||||
kill(ui->selected_pid, SIGKILL);
|
||||
}
|
||||
|
||||
|
@ -841,7 +847,8 @@ _item_menu_priority_increase_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
Proc_Info *proc;
|
||||
|
||||
ui = data;
|
||||
if (!ui) return;
|
||||
|
||||
_item_menu_cancel_cb(ui, NULL, NULL);
|
||||
|
||||
proc = proc_info_by_pid(ui->selected_pid);
|
||||
if (!proc) return;
|
||||
|
@ -860,6 +867,8 @@ _item_menu_priority_decrease_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
|
||||
ui = data;
|
||||
|
||||
_item_menu_cancel_cb(ui, NULL, NULL);
|
||||
|
||||
proc = proc_info_by_pid(ui->selected_pid);
|
||||
if (!proc) return;
|
||||
|
||||
|
@ -877,7 +886,8 @@ _item_menu_debug_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
const char *terminal = "xterm";
|
||||
|
||||
ui = data;
|
||||
if (!ui) return;
|
||||
|
||||
_item_menu_cancel_cb(ui, NULL, NULL);
|
||||
|
||||
proc = proc_info_by_pid(ui->selected_pid);
|
||||
if (!proc) return;
|
||||
|
@ -895,7 +905,9 @@ _item_menu_priority_add(Evas_Object *menu, Elm_Object_Item *menu_it,
|
|||
Ui *ui)
|
||||
{
|
||||
Elm_Object_Item *it;
|
||||
Proc_Info *proc = proc_info_by_pid(ui->selected_pid);
|
||||
Proc_Info *proc;
|
||||
|
||||
proc = proc_info_by_pid(ui->selected_pid);
|
||||
if (!proc) return;
|
||||
|
||||
it = elm_menu_item_add(menu, menu_it, evisum_icon_path_get("window"),
|
||||
|
@ -925,12 +937,13 @@ _item_menu_properties_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
Proc_Info *proc;
|
||||
|
||||
ui = data;
|
||||
if (!ui) return;
|
||||
|
||||
_item_menu_cancel_cb(ui, NULL, NULL);
|
||||
|
||||
proc = proc_info_by_pid(ui->selected_pid);
|
||||
if (!proc) return;
|
||||
|
||||
ui_process_win_add(ui->win, proc->pid, proc->command);
|
||||
ui_process_win_add(ui->win, proc->pid, proc->command, ui->poll_delay);
|
||||
|
||||
proc_info_free(proc);
|
||||
}
|
||||
|
@ -1032,38 +1045,250 @@ _item_pid_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
|||
if (!proc) return;
|
||||
|
||||
ui->selected_pid = proc->pid;
|
||||
ui_process_win_add(ui->win, proc->pid, proc->command);
|
||||
ui_process_win_add(ui->win, proc->pid, proc->command, ui->poll_delay);
|
||||
}
|
||||
|
||||
static void
|
||||
_genlist_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
_about_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui;
|
||||
Evas_Coord w, ow;
|
||||
Ui *ui = data;
|
||||
|
||||
ui = data;
|
||||
evisum_about_window_show(ui);
|
||||
}
|
||||
|
||||
evas_object_geometry_get(ui->genlist_procs, NULL, NULL, &ow, NULL);
|
||||
evas_object_geometry_get(ui->win, NULL, NULL, &w, NULL);
|
||||
static void
|
||||
_menu_memory_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
if (ow > w)
|
||||
elm_genlist_realized_items_update(ui->genlist_procs);
|
||||
ui_win_memory_add(ui);
|
||||
}
|
||||
|
||||
static void
|
||||
_menu_disk_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
ui_win_disk_add(ui);
|
||||
}
|
||||
|
||||
static void
|
||||
_menu_misc_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
ui_win_misc_add(ui);
|
||||
}
|
||||
|
||||
static void
|
||||
_menu_cpu_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
ui_win_cpu_add(ui);
|
||||
}
|
||||
|
||||
static void
|
||||
_menu_effects_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
evisum_ui_effects_enabled_set(!evisum_ui_effects_enabled_get());
|
||||
|
||||
_config_save(ui);
|
||||
ecore_app_restart();
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
static void
|
||||
_main_menu_dismissed_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *ev EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
elm_ctxpopup_dismiss(ui->main_menu);
|
||||
evas_object_del(ui->main_menu);
|
||||
|
||||
ui->main_menu = NULL;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_btn_create(Evas_Object *parent, const char *icon, const char *text, void *cb, void *data)
|
||||
{
|
||||
Evas_Object *ot, *or, *btn, *ic;
|
||||
|
||||
ot = elm_table_add(parent);
|
||||
evas_object_show(ot);
|
||||
|
||||
or = evas_object_rectangle_add(evas_object_evas_get(parent));
|
||||
evas_object_size_hint_min_set(or, 24 * elm_config_scale_get(), 24 * elm_config_scale_get());
|
||||
elm_table_pack(ot, or, 0, 0, 1, 1);
|
||||
|
||||
btn = elm_button_add(parent);
|
||||
evas_object_size_hint_weight_set(btn, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(btn, FILL, FILL);
|
||||
evas_object_show(btn);
|
||||
|
||||
ic = elm_icon_add(btn);
|
||||
elm_icon_standard_set(ic, evisum_icon_path_get(icon));
|
||||
elm_object_part_content_set(btn, "icon", ic);
|
||||
evas_object_show(ic);
|
||||
|
||||
elm_object_tooltip_text_set(btn, text);
|
||||
evas_object_smart_callback_add(btn, "clicked", cb, data);
|
||||
|
||||
elm_table_pack(ot, btn, 0, 0, 1, 1);
|
||||
|
||||
return ot;
|
||||
}
|
||||
|
||||
static void
|
||||
_main_menu_slider_changed_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
ui->poll_delay = elm_slider_value_get(obj) + 0.5;
|
||||
|
||||
if (ui->poll_delay > 1)
|
||||
elm_slider_unit_format_set(obj, _("%1.0f secs"));
|
||||
else
|
||||
elm_slider_unit_format_set(obj, _("%1.0f sec"));
|
||||
|
||||
_config_save(ui);
|
||||
|
||||
_proc_pid_cpu_times_reset(ui);
|
||||
}
|
||||
|
||||
static void
|
||||
_main_menu_create(Ui *ui, Evas_Object *btn)
|
||||
{
|
||||
Evas_Object *o, *bx, *hbox, *sep, *fr, *sli;
|
||||
Evas_Coord ox, oy, ow, oh;
|
||||
|
||||
evas_object_geometry_get(btn, &ox, &oy, &ow, &oh);
|
||||
o = elm_ctxpopup_add(ui->win);
|
||||
evas_object_size_hint_weight_set(o, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(o, FILL, FILL);
|
||||
elm_object_style_set(o, "noblock");
|
||||
|
||||
bx = elm_box_add(o);
|
||||
evas_object_size_hint_weight_set(bx, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(bx, FILL, FILL);
|
||||
evas_object_show(bx);
|
||||
|
||||
fr = elm_frame_add(o);
|
||||
elm_object_text_set(fr, _("Options"));
|
||||
evas_object_size_hint_weight_set(fr, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(fr, FILL, FILL);
|
||||
evas_object_show(fr);
|
||||
|
||||
hbox = elm_box_add(o);
|
||||
elm_box_horizontal_set(hbox, 1);
|
||||
evas_object_size_hint_align_set(hbox, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(hbox, EXPAND, EXPAND);
|
||||
evas_object_show(hbox);
|
||||
|
||||
btn = _btn_create(hbox, "cpu", _("CPU"), _menu_cpu_activity_clicked_cb, ui);
|
||||
elm_box_pack_end(hbox, btn);
|
||||
|
||||
btn = _btn_create(hbox, "memory", _("Memory"), _menu_memory_activity_clicked_cb, ui);
|
||||
elm_box_pack_end(hbox, btn);
|
||||
|
||||
btn = _btn_create(hbox, "storage", _("Storage"), _menu_disk_activity_clicked_cb, ui);
|
||||
elm_box_pack_end(hbox, btn);
|
||||
|
||||
btn = _btn_create(hbox, "misc", _("Misc"), _menu_misc_activity_clicked_cb, ui);
|
||||
elm_box_pack_end(hbox, btn);
|
||||
|
||||
sep = elm_separator_add(hbox);
|
||||
evas_object_size_hint_align_set(sep, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(sep, EXPAND, EXPAND);
|
||||
elm_separator_horizontal_set(sep, 0);
|
||||
evas_object_show(sep);
|
||||
elm_box_pack_end(hbox, sep);
|
||||
|
||||
btn = _btn_create(hbox, "effects", _("Effects"), _menu_effects_clicked_cb, ui);
|
||||
elm_box_pack_end(hbox, btn);
|
||||
|
||||
sep = elm_separator_add(hbox);
|
||||
evas_object_size_hint_align_set(sep, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(sep, EXPAND, EXPAND);
|
||||
elm_separator_horizontal_set(sep, 0);
|
||||
evas_object_show(sep);
|
||||
elm_box_pack_end(hbox, sep);
|
||||
|
||||
btn = _btn_create(hbox, "evisum", _("About"), _about_clicked_cb, ui);
|
||||
elm_box_pack_end(hbox, btn);
|
||||
|
||||
sli = elm_slider_add(o);
|
||||
evas_object_size_hint_weight_set(sli, EXPAND, EXPAND);
|
||||
elm_slider_min_max_set(sli, 1.0, 10.0);
|
||||
elm_slider_span_size_set(sli, 10.0);
|
||||
elm_slider_step_set(sli, 1 / 10.0);
|
||||
elm_slider_indicator_format_set(sli, "%1.0f");
|
||||
elm_slider_unit_format_set(sli, _("%1.0f secs"));
|
||||
elm_slider_value_set(sli, ui->poll_delay);
|
||||
evas_object_size_hint_align_set(sli, FILL, FILL);
|
||||
elm_object_tooltip_text_set(sli, _("Poll delay (seconds)"));
|
||||
evas_object_smart_callback_add(sli, "slider,drag,stop", _main_menu_slider_changed_cb, ui);
|
||||
evas_object_smart_callback_add(sli, "changed", _main_menu_slider_changed_cb, ui);
|
||||
evas_object_show(sli);
|
||||
_main_menu_slider_changed_cb(ui, sli, NULL);
|
||||
|
||||
elm_box_pack_end(bx, hbox);
|
||||
elm_box_pack_end(bx, sli);
|
||||
|
||||
evas_object_size_hint_min_set(fr, 100, 100);
|
||||
elm_object_content_set(fr, bx);
|
||||
elm_object_content_set(o, fr);
|
||||
|
||||
elm_ctxpopup_direction_priority_set(o, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_DOWN,
|
||||
ELM_CTXPOPUP_DIRECTION_LEFT, ELM_CTXPOPUP_DIRECTION_RIGHT);
|
||||
evas_object_move(o, ox + (ow / 2), oy);
|
||||
evas_object_show(o);
|
||||
ui->main_menu = o;
|
||||
}
|
||||
|
||||
static void
|
||||
_btn_menu_clicked_cb(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
if (!ui->main_menu)
|
||||
_main_menu_create(ui, obj);
|
||||
else
|
||||
_main_menu_dismissed_cb(ui, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_content_system_add(Ui *ui)
|
||||
{
|
||||
Evas_Object *parent, *box, *hbox, *frame, *table;
|
||||
Evas_Object *pb, *button, *plist;
|
||||
Evas_Object *parent, *box, *box2, *hbox, *frame, *table;
|
||||
Evas_Object *entry, *pb, *button, *plist, *btn;
|
||||
int i = 0;
|
||||
|
||||
parent = ui->content;
|
||||
|
||||
frame = elm_frame_add(parent);
|
||||
evas_object_size_hint_weight_set(frame, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(frame, FILL, FILL);
|
||||
elm_object_text_set(frame, _("System Overview"));
|
||||
elm_object_style_set(frame, "pad_small");
|
||||
evas_object_show(frame);
|
||||
|
||||
ui->system_activity = box = elm_box_add(parent);
|
||||
evas_object_size_hint_weight_set(box, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(box, FILL, FILL);
|
||||
evas_object_show(box);
|
||||
elm_table_pack(ui->content, ui->system_activity, 0, 1, 1, 1);
|
||||
elm_object_content_set(frame, box);
|
||||
elm_table_pack(ui->content, frame, 0, 1, 1, 1);
|
||||
|
||||
hbox = elm_box_add(box);
|
||||
evas_object_size_hint_weight_set(hbox, EXPAND, 0);
|
||||
|
@ -1076,6 +1301,7 @@ _ui_content_system_add(Ui *ui)
|
|||
evas_object_size_hint_weight_set(frame, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(frame, FILL, FILL);
|
||||
elm_object_text_set(frame, _("System CPU"));
|
||||
elm_object_style_set(frame, "pad_medium");
|
||||
evas_object_show(frame);
|
||||
elm_box_pack_end(hbox, frame);
|
||||
|
||||
|
@ -1083,7 +1309,7 @@ _ui_content_system_add(Ui *ui)
|
|||
evas_object_size_hint_align_set(pb, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(pb, EXPAND, EXPAND);
|
||||
elm_progressbar_span_size_set(pb, 1.0);
|
||||
elm_progressbar_unit_format_set(pb, "%1.2f%%");
|
||||
elm_progressbar_unit_format_set(pb, "%1.2f %%");
|
||||
elm_object_content_set(frame, pb);
|
||||
evas_object_show(pb);
|
||||
|
||||
|
@ -1091,6 +1317,7 @@ _ui_content_system_add(Ui *ui)
|
|||
evas_object_size_hint_weight_set(frame, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(frame, FILL, FILL);
|
||||
elm_object_text_set(frame, _("System Memory"));
|
||||
elm_object_style_set(frame, "pad_medium");
|
||||
evas_object_show(frame);
|
||||
elm_box_pack_end(hbox, frame);
|
||||
|
||||
|
@ -1179,17 +1406,43 @@ _ui_content_system_add(Ui *ui)
|
|||
ui->scroller = ui->genlist_procs = plist = elm_genlist_add(parent);
|
||||
elm_scroller_gravity_set(ui->scroller, 0.0, 1.0);
|
||||
elm_object_focus_allow_set(plist, EINA_FALSE);
|
||||
elm_scroller_movement_block_set(ui->scroller, ELM_SCROLLER_MOVEMENT_BLOCK_HORIZONTAL);
|
||||
elm_scroller_policy_set(ui->scroller, ELM_SCROLLER_POLICY_OFF,
|
||||
ELM_SCROLLER_POLICY_AUTO);
|
||||
elm_genlist_homogeneous_set(plist, EINA_TRUE);
|
||||
elm_genlist_multi_select_set(plist, EINA_FALSE);
|
||||
evas_object_size_hint_weight_set(plist, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(plist, FILL, FILL);
|
||||
evas_object_show(plist);
|
||||
evas_object_event_callback_add(ui->genlist_procs, EVAS_CALLBACK_RESIZE,
|
||||
_genlist_resize_cb, ui);
|
||||
elm_win_resize_object_add(ui->win, plist);
|
||||
|
||||
elm_box_pack_end(box, table);
|
||||
elm_box_pack_end(box, plist);
|
||||
box2 = elm_box_add(parent);
|
||||
evas_object_size_hint_weight_set(box2, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(box2, FILL, FILL);
|
||||
evas_object_show(box2);
|
||||
|
||||
elm_box_pack_end(box2, table);
|
||||
elm_box_pack_end(box2, plist);
|
||||
|
||||
hbox = elm_box_add(parent);
|
||||
evas_object_size_hint_weight_set(hbox, EXPAND, 0);
|
||||
evas_object_size_hint_align_set(hbox, FILL, FILL);
|
||||
elm_box_horizontal_set(hbox, EINA_TRUE);
|
||||
evas_object_show(hbox);
|
||||
elm_box_pack_end(box2, hbox);
|
||||
|
||||
btn = _btn_create(hbox, "menu", NULL, _btn_menu_clicked_cb, ui);
|
||||
elm_box_pack_end(hbox, btn);
|
||||
|
||||
ui->entry_search = entry = elm_entry_add(parent);
|
||||
evas_object_size_hint_weight_set(entry, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(entry, FILL, FILL);
|
||||
elm_entry_single_line_set(entry, EINA_TRUE);
|
||||
elm_entry_scrollable_set(entry, EINA_TRUE);
|
||||
elm_entry_editable_set(entry, EINA_TRUE);
|
||||
evas_object_show(entry);
|
||||
elm_box_pack_end(hbox, entry);
|
||||
|
||||
elm_box_pack_end(ui->system_activity, box2);
|
||||
|
||||
evas_object_smart_callback_add(ui->btn_pid, "clicked",
|
||||
_btn_pid_clicked_cb, ui);
|
||||
|
@ -1213,51 +1466,6 @@ _ui_content_system_add(Ui *ui)
|
|||
_item_unrealized_cb, ui);
|
||||
}
|
||||
|
||||
static void
|
||||
_about_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
evisum_about_window_show(ui);
|
||||
}
|
||||
|
||||
static void
|
||||
_menu_memory_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
ui_win_memory_add(ui);
|
||||
}
|
||||
|
||||
static void
|
||||
_menu_disk_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
ui_win_disk_add(ui);
|
||||
}
|
||||
|
||||
static void
|
||||
_menu_misc_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
ui_win_misc_add(ui);
|
||||
}
|
||||
|
||||
static void
|
||||
_menu_cpu_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
ui_win_cpu_add(ui);
|
||||
}
|
||||
|
||||
static void
|
||||
_evisum_process_filter(Ui *ui, const char *text)
|
||||
{
|
||||
|
@ -1297,8 +1505,7 @@ _evisum_search_keypress_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
|
|||
static Evas_Object *
|
||||
_ui_content_add(Evas_Object *parent, Ui *ui)
|
||||
{
|
||||
Evas_Object *table, *box, *entry, *hbox, *frame;
|
||||
Evas_Object *ic;
|
||||
Evas_Object *table;
|
||||
|
||||
ui->content = table = elm_table_add(parent);
|
||||
evas_object_size_hint_weight_set(table, EXPAND, EXPAND);
|
||||
|
@ -1306,45 +1513,6 @@ _ui_content_add(Evas_Object *parent, Ui *ui)
|
|||
elm_object_content_set(parent, table);
|
||||
evas_object_show(table);
|
||||
|
||||
frame = elm_frame_add(parent);
|
||||
evas_object_size_hint_weight_set(frame, EXPAND, 0);
|
||||
evas_object_size_hint_align_set(frame, FILL, FILL);
|
||||
elm_object_style_set(frame, "pad_medium");
|
||||
evas_object_show(frame);
|
||||
|
||||
hbox = elm_box_add(parent);
|
||||
evas_object_size_hint_weight_set(hbox, EXPAND, 0);
|
||||
evas_object_size_hint_align_set(hbox, FILL, FILL);
|
||||
elm_box_horizontal_set(hbox, EINA_TRUE);
|
||||
evas_object_show(hbox);
|
||||
|
||||
box = elm_box_add(parent);
|
||||
evas_object_size_hint_weight_set(box, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(box, FILL, FILL);
|
||||
elm_box_horizontal_set(box, EINA_TRUE);
|
||||
evas_object_show(box);
|
||||
|
||||
ui->entry_search = entry = elm_entry_add(parent);
|
||||
evas_object_size_hint_weight_set(entry, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(entry, FILL, FILL);
|
||||
elm_entry_single_line_set(entry, EINA_TRUE);
|
||||
elm_entry_scrollable_set(entry, EINA_TRUE);
|
||||
elm_entry_editable_set(entry, EINA_TRUE);
|
||||
evas_object_show(entry);
|
||||
|
||||
ic = elm_icon_add(parent);
|
||||
elm_icon_standard_set(ic, evisum_icon_path_get("find"));
|
||||
evas_object_size_hint_min_set(ic, 24, 24);
|
||||
evas_object_show(ic);
|
||||
evas_object_color_set(ic, 64, 64, 64, 255);
|
||||
elm_object_part_content_set(entry, "icon", ic);
|
||||
|
||||
elm_box_pack_end(box, entry);
|
||||
|
||||
elm_object_content_set(frame, box);
|
||||
elm_box_pack_end(hbox, frame);
|
||||
elm_table_pack(ui->content, hbox, 0, 2, 1, 1);
|
||||
|
||||
_ui_content_system_add(ui);
|
||||
|
||||
return table;
|
||||
|
@ -1381,6 +1549,9 @@ _evisum_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
if (ev->keyname[0] == 'e' || ev->keyname[0] == 'E')
|
||||
ui->show_self = !ui->show_self;
|
||||
|
||||
if (ev->keyname[0] == 'k' || ev->keyname[0] == 'K')
|
||||
proc_info_kthreads_show_set(!proc_info_kthreads_show_get());
|
||||
|
||||
_config_save(ui);
|
||||
}
|
||||
|
||||
|
@ -1389,7 +1560,14 @@ _evisum_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
{
|
||||
Ui *ui = data;
|
||||
|
||||
elm_genlist_realized_items_update(ui->genlist_procs);
|
||||
if (eina_lock_take_try(&_lock))
|
||||
{
|
||||
elm_genlist_realized_items_update(ui->genlist_procs);
|
||||
eina_lock_release(&_lock);
|
||||
}
|
||||
|
||||
if (ui->main_menu)
|
||||
_main_menu_dismissed_cb(ui, NULL, NULL);
|
||||
|
||||
_config_save(ui);
|
||||
}
|
||||
|
@ -1398,9 +1576,7 @@ void
|
|||
evisum_ui_shutdown(Ui *ui)
|
||||
{
|
||||
if (ui->shutdown_now)
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
exit(0);
|
||||
|
||||
if (ui->win_cpu)
|
||||
evas_object_smart_callback_call(ui->win_cpu, "delete,request", NULL);
|
||||
|
@ -1471,10 +1647,8 @@ _system_info_all_poll(void *data, Ecore_Thread *thread)
|
|||
ecore_main_loop_quit();
|
||||
return;
|
||||
}
|
||||
|
||||
ecore_thread_feedback(thread, info);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4 * ui->poll_delay; i++)
|
||||
{
|
||||
if (ecore_thread_check(thread)) return;
|
||||
|
||||
|
@ -1495,6 +1669,7 @@ _system_info_all_poll_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
|
|||
Evas_Object *pb;
|
||||
Sys_Info *info;
|
||||
double ratio, value, cpu_usage = 0.0;
|
||||
int Hz;
|
||||
|
||||
ui = data;
|
||||
info = msg;
|
||||
|
@ -1503,13 +1678,21 @@ _system_info_all_poll_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
|
|||
goto out;
|
||||
|
||||
for (int i = 0; i < info->cpu_count; i++)
|
||||
{
|
||||
cpu_usage += info->cores[i]->percent;
|
||||
}
|
||||
cpu_usage += info->cores[i]->percent;
|
||||
|
||||
cpu_usage = cpu_usage / system_cpu_online_count_get();
|
||||
|
||||
elm_progressbar_value_set(ui->progress_cpu, cpu_usage / 100);
|
||||
Hz = system_cpu_frequency_get();
|
||||
if (Hz != -1)
|
||||
{
|
||||
if (Hz > 1000000)
|
||||
elm_object_tooltip_text_set(ui->progress_cpu, eina_slstr_printf("%1.1f GHz", (double) Hz / 1000000.0));
|
||||
else
|
||||
elm_object_tooltip_text_set(ui->progress_cpu, eina_slstr_printf("%d MHz", Hz / 1000));
|
||||
}
|
||||
|
||||
ui->cpu_usage = cpu_usage;
|
||||
|
||||
if (ui->zfs_mounted)
|
||||
info->memory.used += info->memory.zfs_arc_used;
|
||||
|
@ -1527,49 +1710,34 @@ out:
|
|||
system_info_all_free(info);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_elm_config_change_cb(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
elm_genlist_clear(ui->genlist_procs);
|
||||
_process_list_update(ui);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_launch(Ui *ui)
|
||||
{
|
||||
_process_list_update(ui);
|
||||
|
||||
ecore_timer_add(2.0, _bring_in, ui);
|
||||
elm_object_focus_set(ui->entry_search, EINA_TRUE);
|
||||
|
||||
ui->thread_system =
|
||||
ecore_thread_feedback_run(_system_info_all_poll,
|
||||
_system_info_all_poll_feedback_cb, _thread_end_cb,
|
||||
_thread_error_cb, ui, EINA_FALSE);
|
||||
|
||||
ecore_thread_feedback_run(_system_info_all_poll, _system_info_all_poll_feedback_cb, _thread_end_cb, _thread_error_cb, ui, EINA_FALSE);
|
||||
ui->thread_process =
|
||||
ecore_thread_feedback_run(_process_list, _process_list_feedback_cb,
|
||||
_thread_end_cb, _thread_error_cb, ui, EINA_FALSE);
|
||||
ecore_thread_feedback_run(_process_list, _process_list_feedback_cb, _thread_end_cb, _thread_error_cb, ui, EINA_FALSE);
|
||||
|
||||
evas_object_event_callback_add(ui->win, EVAS_CALLBACK_RESIZE,
|
||||
_evisum_resize_cb, ui);
|
||||
evas_object_event_callback_add(ui->content, EVAS_CALLBACK_KEY_DOWN,
|
||||
_evisum_key_down_cb, ui);
|
||||
evas_object_event_callback_add(ui->entry_search, EVAS_CALLBACK_KEY_DOWN,
|
||||
_evisum_search_keypress_cb, ui);
|
||||
}
|
||||
|
||||
static void
|
||||
_menu_setup(Ui *ui)
|
||||
{
|
||||
Evas_Object *menu;
|
||||
Elm_Object_Item *menu_it;
|
||||
|
||||
menu = elm_win_main_menu_get(ui->win);
|
||||
menu_it = elm_menu_item_add(menu, NULL, NULL, _("File"), NULL, NULL);
|
||||
elm_menu_item_add(menu, menu_it, "exit", _("Quit"), _quit_cb, ui);
|
||||
menu_it = elm_menu_item_add(menu, NULL, NULL, _("View"), NULL, NULL);
|
||||
elm_menu_item_add(menu, menu_it, NULL, _("CPU"), _menu_cpu_activity_clicked_cb, ui);
|
||||
elm_menu_item_add(menu, menu_it, NULL, _("Memory"),
|
||||
_menu_memory_activity_clicked_cb, ui);
|
||||
elm_menu_item_add(menu, menu_it, NULL, _("Storage"),
|
||||
_menu_disk_activity_clicked_cb, ui);
|
||||
elm_menu_item_add(menu, menu_it, NULL, _("Misc"),
|
||||
_menu_misc_activity_clicked_cb, ui);
|
||||
menu_it = elm_menu_item_add(menu, NULL, NULL, _("Help"), NULL, NULL);
|
||||
elm_menu_item_add(menu, menu_it, "evisum", _("About"), _about_clicked_cb, ui);
|
||||
|
||||
evas_object_show(menu);
|
||||
evas_object_event_callback_add(ui->win, EVAS_CALLBACK_RESIZE, _evisum_resize_cb, ui);
|
||||
evas_object_event_callback_add(ui->content, EVAS_CALLBACK_KEY_DOWN, _evisum_key_down_cb, ui);
|
||||
evas_object_event_callback_add(ui->entry_search, EVAS_CALLBACK_KEY_DOWN, _evisum_search_keypress_cb, ui);
|
||||
ecore_event_handler_add(ELM_EVENT_CONFIG_ALL_CHANGED, _elm_config_change_cb, ui);
|
||||
}
|
||||
|
||||
static Ui *
|
||||
|
@ -1587,7 +1755,6 @@ _ui_init(Evas_Object *parent)
|
|||
ui->cpu_times = NULL;
|
||||
ui->cpu_list = NULL;
|
||||
|
||||
// Only take account of the ZFS ARC if there is an active mount.
|
||||
ui->zfs_mounted = file_system_in_use("ZFS");
|
||||
|
||||
_ui = NULL;
|
||||
|
@ -1596,9 +1763,13 @@ _ui_init(Evas_Object *parent)
|
|||
|
||||
_config_load(ui);
|
||||
|
||||
if (evisum_ui_effects_enabled_get())
|
||||
evisum_ui_background_random_add(ui->win, 1);
|
||||
|
||||
_ui_content_add(parent, ui);
|
||||
|
||||
_menu_setup(ui);
|
||||
if (evisum_ui_effects_enabled_get())
|
||||
evisum_ui_animate(ui);
|
||||
|
||||
ui->cache = evisum_ui_item_cache_new(ui->genlist_procs, _item_create, 50);
|
||||
|
||||
|
@ -1615,10 +1786,6 @@ evisum_ui_add(Evas_Object *parent)
|
|||
|
||||
_ui_launch(ui);
|
||||
|
||||
elm_object_focus_set(ui->entry_search, EINA_TRUE);
|
||||
|
||||
ecore_timer_add(2.0, _bring_in, ui);
|
||||
|
||||
return ui;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ typedef enum
|
|||
typedef struct Ui
|
||||
{
|
||||
Evas_Object *win;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *main_menu;
|
||||
Evas_Object *menu;
|
||||
Evas_Object *scroller;
|
||||
Evas_Object *content;
|
||||
|
@ -61,7 +63,6 @@ typedef struct Ui
|
|||
Evisum_Ui_Cache *cache;
|
||||
Evas_Object *genlist_procs;
|
||||
Evas_Object *entry_search;
|
||||
Eina_Bool show_genlist;
|
||||
|
||||
Ecore_Thread *thread_system;
|
||||
Ecore_Thread *thread_process;
|
||||
|
@ -90,11 +91,14 @@ typedef struct Ui
|
|||
Eina_Bool show_self;
|
||||
Eina_Bool shutdown_now;
|
||||
|
||||
Ecore_Animator *animator;
|
||||
Eina_Bool zfs_mounted;
|
||||
|
||||
uint64_t incoming_max;
|
||||
uint64_t outgoing_max;
|
||||
network_t network_usage;
|
||||
|
||||
uint8_t cpu_usage;
|
||||
} Ui;
|
||||
|
||||
Ui *
|
||||
|
|
|
@ -62,11 +62,11 @@ evisum_ui_item_cache_item_release(Evisum_Ui_Cache *cache, Evas_Object *obj)
|
|||
if (it->obj == obj)
|
||||
{
|
||||
it->used = 0;
|
||||
evas_object_hide(it->obj);
|
||||
released = EINA_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return released;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,223 +1,499 @@
|
|||
#include "ui_cpu.h"
|
||||
|
||||
#define COLOR_FG 0xff2f99ff
|
||||
#define COLOR_BG 0xff202020
|
||||
typedef struct {
|
||||
short id;
|
||||
short percent;
|
||||
unsigned int freq;
|
||||
} Core;
|
||||
|
||||
typedef struct {
|
||||
Ui *ui;
|
||||
int cpu_id;
|
||||
Ui *ui;
|
||||
|
||||
Evas_Object *bg;
|
||||
Evas_Object *line;
|
||||
Evas_Object *obj;
|
||||
Evas_Object *btn;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *obj;
|
||||
|
||||
Eina_Bool enabled;
|
||||
Eina_Bool redraw;
|
||||
Evas_Object *colors;
|
||||
|
||||
int pos;
|
||||
double value;
|
||||
double step;
|
||||
} Animate_Data;
|
||||
int cpu_count;
|
||||
|
||||
typedef struct {
|
||||
Ecore_Animator *animator;
|
||||
Animate_Data *anim_data;
|
||||
double *value;
|
||||
Evas_Object *pb;
|
||||
} Progress;
|
||||
Eina_Bool show_cpufreq;
|
||||
// Have cpu scaling
|
||||
Eina_Bool cpu_freq;
|
||||
int freq_min;
|
||||
int freq_max;
|
||||
} Animate;
|
||||
|
||||
typedef struct _Color_Point {
|
||||
unsigned int val;
|
||||
unsigned int color;
|
||||
} Color_Point;
|
||||
|
||||
// config for colors/sizing
|
||||
#define COLOR_CPU_NUM 5
|
||||
static const Color_Point cpu_colormap_in[] = {
|
||||
{ 0, 0xff202020 }, // 0
|
||||
{ 25, 0xff2030a0 }, // 1
|
||||
{ 50, 0xffa040a0 }, // 2
|
||||
{ 75, 0xffff9040 }, // 3
|
||||
{ 100, 0xffffffff }, // 4
|
||||
{ 256, 0xffffffff } // overflow to avoid if's
|
||||
};
|
||||
#define COLOR_FREQ_NUM 4
|
||||
static const Color_Point freq_colormap_in[] = {
|
||||
{ 0, 0xff202020 }, // 0
|
||||
{ 33, 0xff285020 }, // 1
|
||||
{ 67, 0xff30a060 }, // 2
|
||||
{ 100, 0xffa0ff80 }, // 3
|
||||
{ 256, 0xffa0ff80 } // overflow to avoid if's
|
||||
};
|
||||
#define BAR_HEIGHT 2
|
||||
#define COLORS_HEIGHT 20
|
||||
|
||||
// stored colormap tables
|
||||
static unsigned int cpu_colormap[256];
|
||||
static unsigned int freq_colormap[256];
|
||||
|
||||
// handy macros to access argb values from pixels
|
||||
#define AVAL(x) (((x) >> 24) & 0xff)
|
||||
#define RVAL(x) (((x) >> 16) & 0xff)
|
||||
#define GVAL(x) (((x) >> 8) & 0xff)
|
||||
#define BVAL(x) (((x) ) & 0xff)
|
||||
#define ARGB(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
|
||||
|
||||
static void
|
||||
loop_reset(Animate_Data *ad)
|
||||
_color_init(const Color_Point *col_in, unsigned int n, unsigned int *col)
|
||||
{
|
||||
ad->pos = ad->step = 0;
|
||||
}
|
||||
unsigned int pos, interp, val, dist, d;
|
||||
unsigned int a, r, g, b;
|
||||
unsigned int a1, r1, g1, b1, v1;
|
||||
unsigned int a2, r2, g2, b2, v2;
|
||||
|
||||
static Eina_Bool
|
||||
_bg_fill(Animate_Data *ad)
|
||||
{
|
||||
uint32_t *pixels;
|
||||
Evas_Coord x, y, w, h;
|
||||
|
||||
evas_object_geometry_get(ad->bg, NULL, NULL, &w, &h);
|
||||
pixels = evas_object_image_data_get(ad->obj, EINA_TRUE);
|
||||
if (!pixels) return EINA_FALSE;
|
||||
for (y = 0; y < h; y++)
|
||||
// wal colormap_in until colormap table is full
|
||||
for (pos = 0, val = 0; pos < n; pos++)
|
||||
{
|
||||
for (x = 0; x < w; x++)
|
||||
// get first color and value position
|
||||
v1 = col_in[pos].val;
|
||||
a1 = AVAL(col_in[pos].color);
|
||||
r1 = RVAL(col_in[pos].color);
|
||||
g1 = GVAL(col_in[pos].color);
|
||||
b1 = BVAL(col_in[pos].color);
|
||||
// get second color and valuje position
|
||||
v2 = col_in[pos + 1].val;
|
||||
a2 = AVAL(col_in[pos + 1].color);
|
||||
r2 = RVAL(col_in[pos + 1].color);
|
||||
g2 = GVAL(col_in[pos + 1].color);
|
||||
b2 = BVAL(col_in[pos + 1].color);
|
||||
// get distance between values (how many entires to fill)
|
||||
dist = v2 - v1;
|
||||
// walk over the span of colors from point a to point b
|
||||
for (interp = v1; interp < v2; interp++)
|
||||
{
|
||||
*(pixels++) = COLOR_BG;
|
||||
// distance from starting point
|
||||
d = interp - v1;
|
||||
// calculate linear interpolation between start and given d
|
||||
a = ((d * a2) + ((dist - d) * a1)) / dist;
|
||||
r = ((d * r2) + ((dist - d) * r1)) / dist;
|
||||
g = ((d * g2) + ((dist - d) * g1)) / dist;
|
||||
b = ((d * b2) + ((dist - d) * b1)) / dist;
|
||||
// write out resulting color value
|
||||
col[val] = ARGB(a, r, g, b);
|
||||
val++;
|
||||
}
|
||||
}
|
||||
ad->redraw = EINA_FALSE;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
animate(void *data)
|
||||
{
|
||||
uint32_t *pixels;
|
||||
Evas_Object *line, *obj, *bg;
|
||||
Evas_Coord x, y, w, h, fill_y;
|
||||
double value;
|
||||
Animate_Data *ad = data;
|
||||
|
||||
bg = ad->bg; line = ad->line; obj = ad->obj;
|
||||
|
||||
evas_object_geometry_get(bg, &x, &y, &w, &h);
|
||||
evas_object_image_size_set(obj, w, h);
|
||||
|
||||
evas_object_move(line, x + w - ad->pos, y);
|
||||
evas_object_resize(line, 1, h);
|
||||
if (ad->enabled)
|
||||
evas_object_show(line);
|
||||
else
|
||||
evas_object_hide(line);
|
||||
|
||||
if (ad->redraw)
|
||||
{
|
||||
_bg_fill(ad);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
pixels = evas_object_image_data_get(obj, EINA_TRUE);
|
||||
if (!pixels) return EINA_TRUE;
|
||||
|
||||
value = ad->value > 0 ? ad->value : 1.0;
|
||||
|
||||
fill_y = h - (int) ((double)(h / 100.0) * value);
|
||||
|
||||
for (y = 0; ad->enabled && y < h; y++)
|
||||
{
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
if (x == (w - ad->pos))
|
||||
{
|
||||
*(pixels) = COLOR_BG;
|
||||
}
|
||||
if ((x == (w - ad->pos)) && (y >= fill_y))
|
||||
{
|
||||
if (y % 2)
|
||||
*(pixels) = COLOR_FG;
|
||||
}
|
||||
pixels++;
|
||||
}
|
||||
}
|
||||
|
||||
ad->step += (double) (w * ecore_animator_frametime_get()) / 60.0;
|
||||
ad->pos = ad->step;
|
||||
|
||||
if (ad->pos >= w)
|
||||
loop_reset(ad);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_anim_resize_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
_core_times_main_cb(void *data, Ecore_Thread *thread)
|
||||
{
|
||||
Animate_Data *ad = data;
|
||||
|
||||
ad->redraw = EINA_TRUE;
|
||||
loop_reset(ad);
|
||||
|
||||
evas_object_hide(ad->line);
|
||||
}
|
||||
|
||||
static void
|
||||
_anim_move_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Animate_Data *ad = data;
|
||||
|
||||
evas_object_hide(ad->line);
|
||||
}
|
||||
|
||||
static void
|
||||
_btn_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *rect;
|
||||
Animate_Data *ad = data;
|
||||
|
||||
ad->enabled = !ad->enabled;
|
||||
|
||||
rect = elm_object_part_content_get(ad->btn, "elm.swallow.content");
|
||||
if (!ad->enabled)
|
||||
evas_object_color_set(rect, 0, 0, 0, 0);
|
||||
else
|
||||
evas_object_color_set(rect, 47, 153, 255, 255);
|
||||
}
|
||||
|
||||
static void
|
||||
_core_times_cb(void *data, Ecore_Thread *thread)
|
||||
{
|
||||
Progress *progress;
|
||||
cpu_core_t **cores;
|
||||
Eina_List *l;
|
||||
Ui *ui;
|
||||
// this runs in a dedicated thread in the bg sleeping, collecting info
|
||||
// on usage then sending as feedback to mainloop
|
||||
Animate *ad = data;
|
||||
int ncpu;
|
||||
|
||||
ui = data;
|
||||
// when we begin to run - get min and max freq. note - no locks so
|
||||
// not that great... writing to data in thread that mainloop thread
|
||||
// will read
|
||||
if (!system_cpu_frequency_min_max_get(&ad->freq_min, &ad->freq_max))
|
||||
ad->cpu_freq = EINA_TRUE;
|
||||
|
||||
for (int i = 0; !ecore_thread_check(thread); i = 0)
|
||||
// while this thread has not been canceled
|
||||
while (!ecore_thread_check(thread))
|
||||
{
|
||||
cores = system_cpu_usage_get(&ncpu);
|
||||
cpu_core_t **cores = system_cpu_usage_delayed_get(&ncpu, 100000);
|
||||
Core *cores_out = calloc(ncpu, sizeof(Core));
|
||||
|
||||
EINA_LIST_FOREACH(ui->cpu_list, l, progress)
|
||||
// producer-consumer moduel. this thread produces data and sends as
|
||||
// feedback to mainloop to consume
|
||||
if (cores_out)
|
||||
{
|
||||
*progress->value = cores[i]->percent;
|
||||
ecore_thread_main_loop_begin();
|
||||
elm_progressbar_value_set(progress->pb, cores[i]->percent / 100);
|
||||
ecore_thread_main_loop_end();
|
||||
free(cores[i++]);
|
||||
for (int n = 0; n < ncpu; n++)
|
||||
{
|
||||
// Copy our core state data to mainloop
|
||||
Core *core = &(cores_out[n]);
|
||||
core->id = n;
|
||||
core->percent = cores[n]->percent;
|
||||
if (ad->cpu_freq)
|
||||
core->freq = system_cpu_n_frequency_get(n);
|
||||
free(cores[n]);
|
||||
}
|
||||
ecore_thread_feedback(thread, cores_out);
|
||||
}
|
||||
free(cores);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_win_del_cb(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
_update(Animate *ad, Core *cores)
|
||||
{
|
||||
Progress *progress;
|
||||
Ui *ui = data;
|
||||
Evas_Object *obj = ad->obj;
|
||||
unsigned int *pixels, *pix;
|
||||
Evas_Coord x, y, w, h;
|
||||
int iw, stride;
|
||||
Eina_Bool clear = EINA_FALSE;
|
||||
|
||||
ecore_thread_cancel(ui->thread_cpu);
|
||||
|
||||
EINA_LIST_FREE(ui->cpu_list, progress)
|
||||
evas_object_geometry_get(obj, &x, &y, &w, &h);
|
||||
evas_object_image_size_get(obj, &iw, NULL);
|
||||
// if image pixel size doesn't match geom - we need to resize, so set
|
||||
// new size and mark it for clearing when we fill
|
||||
if (iw != w)
|
||||
{
|
||||
ecore_animator_del(progress->animator);
|
||||
free(progress->anim_data);
|
||||
free(progress);
|
||||
evas_object_image_size_set(obj, w, ad->cpu_count * 2);
|
||||
clear = EINA_TRUE;
|
||||
}
|
||||
|
||||
ecore_thread_wait(ui->thread_cpu, 1.0);
|
||||
evas_object_del(obj);
|
||||
// get pixel data ptr
|
||||
pixels = evas_object_image_data_get(obj, EINA_TRUE);
|
||||
if (!pixels) return;
|
||||
// get stride (# of bytes per line)
|
||||
stride = evas_object_image_stride_get(obj);
|
||||
|
||||
// go throuhg al the cpu cores
|
||||
for (y = 0; y < ad->cpu_count; y++)
|
||||
{
|
||||
Core *core = &(cores[y]);
|
||||
unsigned int c1, c2;
|
||||
|
||||
// our pix ptr is the pixel row and y is both y pixel coord and core
|
||||
if (clear)
|
||||
{
|
||||
// clear/fill with 0 value from colormap
|
||||
pix = &(pixels[(y * 2) * (stride / 4)]);
|
||||
for (x = 0; x < (w - 1); x++) pix[x] = cpu_colormap[0];
|
||||
pix = &(pixels[((y * 2) + 1) * (stride / 4)]);
|
||||
for (x = 0; x < (w - 1); x++) pix[x] = freq_colormap[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
// scroll pixels 1 to the left
|
||||
pix = &(pixels[(y * 2) * (stride / 4)]);
|
||||
for (x = 0; x < (w - 1); x++) pix[x] = pix[x + 1];
|
||||
pix = &(pixels[((y * 2) + 1) * (stride / 4)]);
|
||||
for (x = 0; x < (w - 1); x++) pix[x] = pix[x + 1];
|
||||
}
|
||||
// final pixel on end of each row... set it to a new value
|
||||
// get color from cpu colormap
|
||||
// last pixel == resulting pixel color
|
||||
c1 = cpu_colormap[core->percent & 0xff];
|
||||
pix = &(pixels[(y * 2) * (stride / 4)]);
|
||||
pix[x] = c1;
|
||||
// 2nd row of pixles for freq
|
||||
if ((ad->show_cpufreq) && (ad->cpu_freq))
|
||||
{
|
||||
int v = core->freq - ad->freq_min;
|
||||
int d = ad->freq_max - ad->freq_min;
|
||||
|
||||
// if there is a difference between min and max ... a range
|
||||
if (d > 0)
|
||||
{
|
||||
v = (100 * v) / d;
|
||||
if (v < 0) v = 0;
|
||||
else if (v > 100) v = 100;
|
||||
// v now is 0->100 as a percentage of possible frequency
|
||||
// the cpu can do
|
||||
c2 = freq_colormap[v & 0xff];
|
||||
}
|
||||
else c2 = freq_colormap[0];
|
||||
pix = &(pixels[((y * 2) + 1) * (stride / 4)]);
|
||||
pix[x] = c2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no freq show - then just repeat cpu usage color
|
||||
pix = &(pixels[((y * 2) + 1) * (stride / 4)]);
|
||||
pix[x] = c1;
|
||||
}
|
||||
}
|
||||
// hand back pixel data ptr so evas knows we are done with it
|
||||
evas_object_image_data_set(obj, pixels);
|
||||
// now add update region for all pixels in the image at the end as we
|
||||
// changed everything
|
||||
evas_object_image_data_update_add(obj, 0, 0, w, ad->cpu_count * 2);
|
||||
}
|
||||
|
||||
static void
|
||||
_core_times_feedback_cb(void *data, Ecore_Thread *thread EINA_UNUSED, void *msgdata)
|
||||
{
|
||||
// when the thread sends feedback to mainloop, the feedback is cpu and freq
|
||||
// stat info from the feedback thread, so update based on that info then
|
||||
// free it as we don't need it anyway - producer+consumer model
|
||||
Animate *ad = data;
|
||||
Core *cores = msgdata;
|
||||
_update(ad, cores);
|
||||
free(cores);
|
||||
}
|
||||
|
||||
static void
|
||||
_win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Animate *ad = data;
|
||||
Ui *ui = ad->ui;
|
||||
|
||||
// on deletion of window, cancel thread, free animate data and set cpu
|
||||
// dialog handle to null
|
||||
ecore_thread_cancel(ui->thread_cpu);
|
||||
ecore_thread_wait(ui->thread_cpu, 0.5);
|
||||
free(ad);
|
||||
ui->win_cpu = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_check_changed_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Animate *ad = data;
|
||||
// sho freq overlay check changed
|
||||
ad->show_cpufreq = elm_check_state_get(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_colors_fill(Evas_Object *colors)
|
||||
{
|
||||
// fill a 2 pixel high (and 100 wide) image with 2 gradients matching
|
||||
// the colormaps we calculated as a legend
|
||||
int x, stride;
|
||||
unsigned int *pixels;
|
||||
|
||||
evas_object_image_size_set(colors, 101, 2);
|
||||
pixels = evas_object_image_data_get(colors, EINA_TRUE);
|
||||
if (!pixels) return;
|
||||
stride = evas_object_image_stride_get(colors);
|
||||
// cpu percent (first row)
|
||||
for (x = 0; x <= 100; x++) pixels[x] = cpu_colormap[x];
|
||||
// cpu freq (next row)
|
||||
for (x = 0; x <= 100; x++) pixels[x + (stride / 4)] = freq_colormap[x];
|
||||
evas_object_image_data_set(colors, pixels);
|
||||
evas_object_image_data_update_add(colors, 0, 0, 101, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_graph(Ui *ui, Evas_Object *parent)
|
||||
{
|
||||
Evas_Object *frame, *tbl, *box, *obj, *ic, *lb, *rec;
|
||||
Evas_Object *fr, *bx, *colors, *check;
|
||||
int i, f;
|
||||
char buf[128];
|
||||
|
||||
Animate *ad = calloc(1, sizeof(Animate));
|
||||
if (!ad) return;
|
||||
|
||||
ad->cpu_count = system_cpu_online_count_get();
|
||||
if (!system_cpu_frequency_min_max_get(&ad->freq_min, &ad->freq_max))
|
||||
ad->cpu_freq = EINA_TRUE;
|
||||
|
||||
// init colormaps from a small # of points
|
||||
_color_init(cpu_colormap_in, COLOR_CPU_NUM, cpu_colormap);
|
||||
_color_init(freq_colormap_in, COLOR_FREQ_NUM, freq_colormap);
|
||||
|
||||
box = parent;
|
||||
|
||||
frame = elm_frame_add(box);
|
||||
evas_object_size_hint_align_set(frame, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(frame, EXPAND, EXPAND);
|
||||
evas_object_show(frame);
|
||||
if (ad->cpu_count > 1)
|
||||
elm_object_text_set(frame, eina_slstr_printf(_("%d CPU Cores"), ad->cpu_count));
|
||||
else
|
||||
elm_object_text_set(frame, _("ONE CPU CORE...MAKE IT COUNT!!!"));
|
||||
|
||||
tbl = elm_table_add(box);
|
||||
evas_object_size_hint_align_set(tbl, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(tbl, EXPAND, EXPAND);
|
||||
evas_object_show(tbl);
|
||||
|
||||
obj = evas_object_image_add(evas_object_evas_get(parent));
|
||||
evas_object_size_hint_align_set(obj, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(obj, EXPAND, EXPAND);
|
||||
evas_object_image_smooth_scale_set(obj, EINA_FALSE);
|
||||
evas_object_image_filled_set(obj, EINA_TRUE);
|
||||
evas_object_image_alpha_set(obj, EINA_FALSE);
|
||||
evas_object_show(obj);
|
||||
|
||||
elm_table_pack(tbl, obj, 0, 0, 5, ad->cpu_count);
|
||||
|
||||
for (i = 0; i < ad->cpu_count; i++)
|
||||
{
|
||||
rec = evas_object_rectangle_add(evas_object_evas_get(parent));
|
||||
evas_object_color_set(rec, 0, 0, 0, 0);
|
||||
evas_object_size_hint_min_set(rec, ELM_SCALE_SIZE(8), ELM_SCALE_SIZE(8));
|
||||
evas_object_size_hint_weight_set(rec, 0.0, EXPAND);
|
||||
elm_table_pack(tbl, rec, 0, i, 1, 1);
|
||||
|
||||
rec = evas_object_rectangle_add(evas_object_evas_get(parent));
|
||||
evas_object_color_set(rec, 0, 0, 0, 0);
|
||||
evas_object_size_hint_min_set(rec, ELM_SCALE_SIZE(24), ELM_SCALE_SIZE(24));
|
||||
evas_object_size_hint_weight_set(rec, 0.0, EXPAND);
|
||||
elm_table_pack(tbl, rec, 1, i, 1, 1);
|
||||
|
||||
ic = elm_icon_add(parent);
|
||||
elm_icon_standard_set(ic, evisum_icon_path_get("cpu"));
|
||||
evas_object_size_hint_align_set(ic, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(ic, 0.0, EXPAND);
|
||||
elm_table_pack(tbl, ic, 1, i, 1, 1);
|
||||
evas_object_show(ic);
|
||||
|
||||
rec = evas_object_rectangle_add(evas_object_evas_get(parent));
|
||||
evas_object_color_set(rec, 0, 0, 0, 0);
|
||||
evas_object_size_hint_min_set(rec, ELM_SCALE_SIZE(8), ELM_SCALE_SIZE(8));
|
||||
evas_object_size_hint_weight_set(rec, 0.0, EXPAND);
|
||||
elm_table_pack(tbl, rec, 2, i, 1, 1);
|
||||
|
||||
lb = elm_label_add(parent);
|
||||
snprintf(buf, sizeof(buf), "<b><color=#fff>%i</></>", i);
|
||||
elm_object_text_set(lb, buf);
|
||||
evas_object_size_hint_align_set(lb, 1.0, 0.5);
|
||||
evas_object_size_hint_weight_set(lb, 0.0, EXPAND);
|
||||
elm_table_pack(tbl, lb, 3, i, 1, 1);
|
||||
evas_object_show(lb);
|
||||
}
|
||||
|
||||
bx = elm_box_add(box);
|
||||
evas_object_size_hint_align_set(bx, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(bx, EXPAND, EXPAND);
|
||||
evas_object_show(bx);
|
||||
elm_box_pack_end(bx, tbl);
|
||||
|
||||
// Set the main content.
|
||||
elm_object_content_set(frame, bx);
|
||||
elm_box_pack_end(box, frame);
|
||||
|
||||
tbl = elm_table_add(box);
|
||||
evas_object_size_hint_align_set(tbl, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(tbl, EXPAND, 0);
|
||||
evas_object_show(tbl);
|
||||
|
||||
fr = elm_frame_add(box);
|
||||
evas_object_size_hint_align_set(fr, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(fr, EXPAND, 0);
|
||||
evas_object_show(fr);
|
||||
elm_object_text_set(fr, _("Legend"));
|
||||
elm_object_content_set(fr, tbl);
|
||||
|
||||
colors = evas_object_image_add(evas_object_evas_get(fr));
|
||||
evas_object_size_hint_min_set
|
||||
(colors, 100, COLORS_HEIGHT * elm_config_scale_get());
|
||||
evas_object_size_hint_align_set(colors, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(colors, EXPAND, EXPAND);
|
||||
evas_object_image_smooth_scale_set(colors, EINA_FALSE);
|
||||
evas_object_image_filled_set(colors, EINA_TRUE);
|
||||
evas_object_image_alpha_set(colors, EINA_FALSE);
|
||||
_colors_fill(colors);
|
||||
elm_table_pack(tbl, colors, 0, 0, 2, 2);
|
||||
evas_object_show(colors);
|
||||
|
||||
lb = elm_label_add(parent);
|
||||
elm_object_text_set(lb, "<b><color=#fff>0%</></>");
|
||||
evas_object_size_hint_align_set(lb, 0.0, 0.5);
|
||||
evas_object_size_hint_weight_set(lb, EXPAND, EXPAND);
|
||||
elm_table_pack(tbl, lb, 0, 0, 1, 1);
|
||||
evas_object_show(lb);
|
||||
|
||||
lb = elm_label_add(parent);
|
||||
f = (ad->freq_min + 500) / 1000;
|
||||
if (f < 1000)
|
||||
snprintf(buf, sizeof(buf), "<b><color=#fff>%iMHz</></>", f);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "<b><color=#fff>%1.1fGHz</></>", ((double)f + 0.05) / 1000.0);
|
||||
elm_object_text_set(lb, buf);
|
||||
evas_object_size_hint_align_set(lb, 0.0, 0.5);
|
||||
evas_object_size_hint_weight_set(lb, EXPAND, EXPAND);
|
||||
elm_table_pack(tbl, lb, 0, 1, 1, 1);
|
||||
evas_object_show(lb);
|
||||
|
||||
lb = elm_label_add(parent);
|
||||
elm_object_text_set(lb, "<b><color=#fff>100%</></>");
|
||||
evas_object_size_hint_align_set(lb, 1.0, 0.5);
|
||||
evas_object_size_hint_weight_set(lb, EXPAND, EXPAND);
|
||||
elm_table_pack(tbl, lb, 1, 0, 1, 1);
|
||||
evas_object_show(lb);
|
||||
|
||||
lb = elm_label_add(parent);
|
||||
f = (ad->freq_max + 500) / 1000;
|
||||
if (f < 1000)
|
||||
snprintf(buf, sizeof(buf), "<b><color=#fff>%iMHz</></>", f);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "<b><color=#fff>%1.1fGHz</></>", ((double)f + 0.05) / 1000.0);
|
||||
elm_object_text_set(lb, buf);
|
||||
evas_object_size_hint_align_set(lb, 1.0, 0.5);
|
||||
evas_object_size_hint_weight_set(lb, EXPAND, EXPAND);
|
||||
elm_table_pack(tbl, lb, 1, 1, 1, 1);
|
||||
evas_object_show(lb);
|
||||
|
||||
elm_box_pack_end(box, fr);
|
||||
|
||||
fr = elm_frame_add(box);
|
||||
elm_frame_autocollapse_set(fr, EINA_TRUE);
|
||||
evas_object_size_hint_align_set(fr, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(fr, EXPAND, 0);
|
||||
evas_object_show(fr);
|
||||
elm_object_text_set(fr, _("Options"));
|
||||
elm_box_pack_end(box, fr);
|
||||
|
||||
check = elm_check_add(fr);
|
||||
evas_object_size_hint_align_set(check, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(check, EXPAND, 0);
|
||||
elm_object_text_set(check, _("Overlay CPU frequency?"));
|
||||
if (!ad->cpu_freq) elm_object_disabled_set(check, 1);
|
||||
evas_object_show(check);
|
||||
elm_object_content_set(fr, check);
|
||||
|
||||
ad->obj = obj;
|
||||
ad->ui = ui;
|
||||
ad->colors = colors;
|
||||
|
||||
// min size ofr cpu color graph to show all cores.
|
||||
evas_object_size_hint_min_set
|
||||
(obj, 100, (BAR_HEIGHT * ad->cpu_count) * elm_config_scale_get());
|
||||
|
||||
evas_object_smart_callback_add(check, "changed", _check_changed_cb, ad);
|
||||
// since win is on auto-delete, just listen for when it is deleted,
|
||||
// whatever the cause/reason
|
||||
evas_object_event_callback_add(ui->win_cpu, EVAS_CALLBACK_DEL, _win_del_cb, ad);
|
||||
|
||||
// run a feedback thread that sends feedback to the mainloop
|
||||
ui->thread_cpu = ecore_thread_feedback_run(_core_times_main_cb,
|
||||
_core_times_feedback_cb,
|
||||
NULL,
|
||||
NULL,
|
||||
ad, EINA_TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
ui_win_cpu_add(Ui *ui)
|
||||
{
|
||||
Evas_Object *win, *box, *hbox, *scroller, *frame;
|
||||
Evas_Object *pb, *tbl, *lbox, *btn, *rect;
|
||||
Evas_Object *bg, *line, *obj;
|
||||
int cpu_count;
|
||||
Evas_Object *win, *box, *scroller;
|
||||
|
||||
if (ui->win_cpu) return;
|
||||
if (ui->win_cpu)
|
||||
{
|
||||
elm_win_raise(ui->win_cpu);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->win_cpu = win = elm_win_util_dialog_add(ui->win, "evisum",
|
||||
ui->win_cpu = win = elm_win_util_standard_add("evisum",
|
||||
_("CPU Usage"));
|
||||
elm_win_autodel_set(win, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(win, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(win, FILL, FILL);
|
||||
|
||||
hbox = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(hbox, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(hbox, FILL, FILL);
|
||||
elm_box_horizontal_set(hbox, EINA_TRUE);
|
||||
evas_object_show(hbox);
|
||||
evisum_ui_background_random_add(win, evisum_ui_effects_enabled_get());
|
||||
|
||||
scroller = elm_scroller_add(win);
|
||||
evas_object_size_hint_weight_set(scroller, EXPAND, EXPAND);
|
||||
|
@ -226,114 +502,16 @@ ui_win_cpu_add(Ui *ui)
|
|||
ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
|
||||
evas_object_show(scroller);
|
||||
|
||||
box = elm_box_add(hbox);
|
||||
box = elm_box_add(win);
|
||||
evas_object_size_hint_align_set(box, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(box, 0.1, EXPAND);
|
||||
evas_object_size_hint_weight_set(box, EXPAND, EXPAND);
|
||||
evas_object_show(box);
|
||||
|
||||
cpu_count = system_cpu_online_count_get();
|
||||
for (int i = 0; i < cpu_count; i++)
|
||||
{
|
||||
lbox = elm_box_add(box);
|
||||
evas_object_size_hint_align_set(lbox, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(lbox, 0.1, EXPAND);
|
||||
evas_object_show(lbox);
|
||||
elm_box_horizontal_set(lbox, EINA_TRUE);
|
||||
|
||||
btn = elm_button_add(box);
|
||||
evas_object_show(btn);
|
||||
|
||||
rect = evas_object_rectangle_add(evas_object_evas_get(box));
|
||||
evas_object_size_hint_min_set(rect, 16 * elm_config_scale_get(),
|
||||
16 * elm_config_scale_get());
|
||||
evas_object_color_set(rect, 47, 153, 255, 255);
|
||||
evas_object_show(rect);
|
||||
elm_object_part_content_set(btn, "elm.swallow.content", rect);
|
||||
|
||||
frame = elm_frame_add(box);
|
||||
evas_object_size_hint_align_set(frame, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(frame, 0, EXPAND);
|
||||
evas_object_show(frame);
|
||||
elm_object_style_set(frame, "pad_small");
|
||||
|
||||
pb = elm_progressbar_add(frame);
|
||||
evas_object_size_hint_align_set(pb, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(pb, 0.1, EXPAND);
|
||||
elm_progressbar_span_size_set(pb, 1.0);
|
||||
elm_progressbar_unit_format_set(pb, "%1.2f%%");
|
||||
evas_object_show(pb);
|
||||
|
||||
elm_box_pack_end(lbox, btn);
|
||||
elm_box_pack_end(lbox, pb);
|
||||
|
||||
tbl = elm_table_add(box);
|
||||
evas_object_size_hint_align_set(tbl, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(tbl, EXPAND, EXPAND);
|
||||
evas_object_show(tbl);
|
||||
|
||||
bg = evas_object_rectangle_add(evas_object_evas_get(box));
|
||||
evas_object_size_hint_align_set(bg, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(bg, EXPAND, EXPAND);
|
||||
evas_object_show(bg);
|
||||
evas_object_size_hint_min_set(bg, 1, 80);
|
||||
|
||||
line = evas_object_rectangle_add(evas_object_evas_get(bg));
|
||||
evas_object_size_hint_align_set(line, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(line, EXPAND, EXPAND);
|
||||
evas_object_color_set(line, 255, 47, 153, 255);
|
||||
evas_object_size_hint_max_set(line, 1, -1);
|
||||
evas_object_show(line);
|
||||
|
||||
obj = evas_object_image_add(evas_object_evas_get(bg));
|
||||
evas_object_size_hint_align_set(obj, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(obj, EXPAND, EXPAND);
|
||||
evas_object_image_filled_set(obj, EINA_TRUE);
|
||||
evas_object_image_colorspace_set(obj, EVAS_COLORSPACE_ARGB8888);
|
||||
evas_object_show(obj);
|
||||
|
||||
elm_table_pack(tbl, bg, 0, 1, 1, 1);
|
||||
elm_table_pack(tbl, obj, 0, 1, 1, 1);
|
||||
elm_table_pack(tbl, line, 0, 1, 1, 1);
|
||||
|
||||
elm_box_pack_end(lbox, tbl);
|
||||
elm_object_content_set(frame, lbox);
|
||||
elm_box_pack_end(box, frame);
|
||||
|
||||
Animate_Data *ad = calloc(1, sizeof(Animate_Data));
|
||||
if (!ad) return;
|
||||
|
||||
ad->bg = bg;
|
||||
ad->obj = obj;
|
||||
ad->line = line;
|
||||
ad->enabled = EINA_TRUE;
|
||||
ad->btn = btn;
|
||||
ad->cpu_id = i;
|
||||
ad->ui = ui;
|
||||
ad->redraw = EINA_TRUE;
|
||||
|
||||
evas_object_smart_callback_add(btn, "clicked", _btn_clicked_cb, ad);
|
||||
evas_object_smart_callback_add(tbl, "resize", _anim_resize_cb, ad);
|
||||
evas_object_smart_callback_add(tbl, "move", _anim_move_cb, ad);
|
||||
|
||||
Progress *progress = calloc(1, sizeof(Progress));
|
||||
if (progress)
|
||||
{
|
||||
progress->pb = pb;
|
||||
progress->value = &ad->value;
|
||||
progress->animator = ecore_animator_add(animate, ad);
|
||||
progress->anim_data = ad;
|
||||
|
||||
ui->cpu_list = eina_list_append(ui->cpu_list, progress);
|
||||
}
|
||||
}
|
||||
|
||||
ui->thread_cpu = ecore_thread_run(_core_times_cb, NULL, NULL, ui);
|
||||
|
||||
elm_box_pack_end(hbox, box);
|
||||
elm_object_content_set(scroller, hbox);
|
||||
_graph(ui, box);
|
||||
|
||||
elm_object_content_set(scroller, box);
|
||||
elm_object_content_set(win, scroller);
|
||||
evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ui);
|
||||
|
||||
evisum_child_window_show(ui->win, win);
|
||||
}
|
||||
|
||||
|
|
|
@ -171,12 +171,17 @@ ui_win_disk_add(Ui *ui)
|
|||
Evas_Object *win, *box, *vbox, *scroller;
|
||||
Evas_Object *table, *rect;
|
||||
|
||||
if (ui->win_disk) return;
|
||||
if (ui->win_disk)
|
||||
{
|
||||
elm_win_raise(ui->win_disk);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->win_disk = win = elm_win_util_dialog_add(ui->win, "evisum",
|
||||
ui->win_disk = win = elm_win_util_standard_add("evisum",
|
||||
_("Storage"));
|
||||
evas_object_size_hint_weight_set(win, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(win, FILL, FILL);
|
||||
evisum_ui_background_random_add(win, evisum_ui_effects_enabled_get());
|
||||
|
||||
box = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(box, EXPAND, EXPAND);
|
||||
|
|
|
@ -125,15 +125,20 @@ ui_win_memory_add(Ui *ui)
|
|||
Evas_Object *win, *frame, *pb;
|
||||
Evas_Object *border, *rect, *label, *table;
|
||||
|
||||
if (ui->win_mem) return;
|
||||
if (ui->win_mem)
|
||||
{
|
||||
elm_win_raise(ui->win_mem);
|
||||
return;
|
||||
}
|
||||
|
||||
Widgets *widgets = calloc(1, sizeof(Widgets));
|
||||
if (!widgets) return;
|
||||
|
||||
ui->win_mem = win = elm_win_util_dialog_add(ui->win, "evisum",
|
||||
ui->win_mem = win = elm_win_util_standard_add("evisum",
|
||||
_("Memory Usage"));
|
||||
evas_object_size_hint_weight_set(win, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(win, FILL, FILL);
|
||||
evisum_ui_background_random_add(win, evisum_ui_effects_enabled_get());
|
||||
|
||||
frame = elm_frame_add(win);
|
||||
evas_object_size_hint_weight_set(frame, EXPAND, EXPAND);
|
||||
|
@ -200,5 +205,5 @@ ui_win_memory_add(Ui *ui)
|
|||
|
||||
_memory_update(widgets);
|
||||
|
||||
ui->timer_memory = ecore_timer_add(3.0, _memory_update, widgets);
|
||||
ui->timer_memory = ecore_timer_add(ui->poll_delay, _memory_update, widgets);
|
||||
}
|
||||
|
|
|
@ -344,11 +344,16 @@ ui_win_misc_add(Ui *ui)
|
|||
Evas_Object *win, *box, *hbox, *frame, *scroller;
|
||||
Evas_Object *table, *border, *rect;
|
||||
|
||||
if (ui->win_misc) return;
|
||||
if (ui->win_misc)
|
||||
{
|
||||
elm_win_raise(ui->win_misc);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->win_misc = win = elm_win_util_dialog_add(ui->win, "evisum", _("Stuff"));
|
||||
ui->win_misc = win = elm_win_util_standard_add("evisum", _("Misc"));
|
||||
evas_object_size_hint_weight_set(win, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(win, FILL, FILL);
|
||||
evisum_ui_background_random_add(win, evisum_ui_effects_enabled_get());
|
||||
|
||||
box = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(box, EXPAND, EXPAND);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include "../system/process.h"
|
||||
#include "util.c"
|
||||
|
||||
static Eina_Lock _lock;
|
||||
|
||||
typedef struct {
|
||||
int tid;
|
||||
char *name;
|
||||
|
@ -284,6 +286,8 @@ _thread_info_set(Ui_Process *ui, Proc_Info *proc)
|
|||
Elm_Object_Item *it;
|
||||
Eina_List *l, *threads = NULL;
|
||||
|
||||
eina_lock_take(&_lock);
|
||||
|
||||
if (!ui->hash_cpu_times)
|
||||
ui->hash_cpu_times = eina_hash_string_superfast_new(_hash_free_cb);
|
||||
|
||||
|
@ -322,13 +326,19 @@ _thread_info_set(Ui_Process *ui, Proc_Info *proc)
|
|||
|
||||
EINA_LIST_FREE(threads, t)
|
||||
{
|
||||
Thread_Info *prev = elm_object_item_data_get(it);
|
||||
if (prev)
|
||||
_item_del(prev, NULL);
|
||||
elm_object_item_data_set(it, t);
|
||||
elm_genlist_item_update(it);
|
||||
it = elm_genlist_item_next_get(it);
|
||||
if (!it)
|
||||
_item_del(t, NULL);
|
||||
else
|
||||
{
|
||||
Thread_Info *prev = elm_object_item_data_get(it);
|
||||
if (prev)
|
||||
_item_del(prev, NULL);
|
||||
elm_object_item_data_set(it, t);
|
||||
elm_genlist_item_update(it);
|
||||
it = elm_genlist_item_next_get(it);
|
||||
}
|
||||
}
|
||||
eina_lock_release(&_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -337,6 +347,20 @@ _win_title_set(Evas_Object *win, const char *fmt, const char *cmd, int pid)
|
|||
elm_win_title_set(win, eina_slstr_printf(fmt, cmd, pid));
|
||||
}
|
||||
|
||||
static char *
|
||||
_time_string(int64_t epoch)
|
||||
{
|
||||
struct tm *info;
|
||||
time_t rawtime;
|
||||
char buf[256];
|
||||
|
||||
rawtime = (time_t) epoch;
|
||||
info = localtime(&rawtime);
|
||||
strftime(buf, sizeof(buf), "%F %T", info);
|
||||
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_proc_info_update(void *data)
|
||||
{
|
||||
|
@ -391,6 +415,7 @@ _proc_info_update(void *data)
|
|||
elm_object_text_set(ui->entry_pid_uid, eina_slstr_printf("%d", proc->uid));
|
||||
elm_object_text_set(ui->entry_pid_cpu,
|
||||
eina_slstr_printf("%d", proc->cpu_id));
|
||||
elm_object_text_set(ui->entry_pid_ppid, eina_slstr_printf("%d", proc->ppid));
|
||||
elm_object_text_set(ui->entry_pid_threads,
|
||||
eina_slstr_printf("%d", proc->numthreads));
|
||||
elm_object_text_set(ui->entry_pid_virt, evisum_size_format(proc->mem_virt));
|
||||
|
@ -402,6 +427,13 @@ _proc_info_update(void *data)
|
|||
evisum_size_format(proc->mem_shared));
|
||||
#endif
|
||||
elm_object_text_set(ui->entry_pid_size, evisum_size_format(proc->mem_size));
|
||||
|
||||
char *t = _time_string(proc->start);
|
||||
if (t)
|
||||
{
|
||||
elm_object_text_set(ui->entry_pid_started, t);
|
||||
free(t);
|
||||
}
|
||||
elm_object_text_set(ui->entry_pid_nice, eina_slstr_printf("%d", proc->nice));
|
||||
elm_object_text_set(ui->entry_pid_pri,
|
||||
eina_slstr_printf("%d", proc->priority));
|
||||
|
@ -489,6 +521,7 @@ _process_tab_add(Evas_Object *parent, Ui_Process *ui)
|
|||
Evas_Object *frame, *hbox, *table;
|
||||
Evas_Object *label, *entry, *button, *border;
|
||||
int i = 0;
|
||||
int r, g, b, a;
|
||||
|
||||
frame = elm_frame_add(parent);
|
||||
elm_object_text_set(frame, _("General"));
|
||||
|
@ -496,6 +529,12 @@ _process_tab_add(Evas_Object *parent, Ui_Process *ui)
|
|||
evas_object_size_hint_align_set(frame, FILL, FILL);
|
||||
evas_object_show(frame);
|
||||
|
||||
if (evisum_ui_effects_enabled_get())
|
||||
{
|
||||
evas_object_color_get(frame, &r, &g, &b, &a);
|
||||
evas_object_color_set(frame, r * 0.75, g * 0.75, b * 0.75, a * 0.75);
|
||||
}
|
||||
|
||||
table = elm_table_add(parent);
|
||||
evas_object_size_hint_weight_set(table, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(table, FILL, FILL);
|
||||
|
@ -527,6 +566,11 @@ _process_tab_add(Evas_Object *parent, Ui_Process *ui)
|
|||
ui->entry_pid_uid = entry = _entry_add(parent);
|
||||
elm_table_pack(table, entry, 1, i++, 1, 1);
|
||||
|
||||
label = _label_add(parent, _("PPID:"));
|
||||
elm_table_pack(table, label, 0, i, 1, 1);
|
||||
ui->entry_pid_ppid = entry = _entry_add(parent);
|
||||
elm_table_pack(table, entry, 1, i++, 1, 1);
|
||||
|
||||
#if defined(__MacOS__)
|
||||
label = _label_add(parent, _("WQ #:"));
|
||||
#else
|
||||
|
@ -561,6 +605,11 @@ _process_tab_add(Evas_Object *parent, Ui_Process *ui)
|
|||
ui->entry_pid_virt = entry = _entry_add(parent);
|
||||
elm_table_pack(table, entry, 1, i++, 1, 1);
|
||||
|
||||
label = _label_add(parent, _(" Start time:"));
|
||||
elm_table_pack(table, label, 0, i, 1, 1);
|
||||
ui->entry_pid_started = entry = _entry_add(parent);
|
||||
elm_table_pack(table, entry, 1, i++, 1, 1);
|
||||
|
||||
label = _label_add(parent, _("Nice:"));
|
||||
elm_table_pack(table, label, 0, i, 1, 1);
|
||||
ui->entry_pid_nice = entry = _entry_add(parent);
|
||||
|
@ -600,7 +649,7 @@ _process_tab_add(Evas_Object *parent, Ui_Process *ui)
|
|||
elm_object_style_set(border, "pad_small");
|
||||
evas_object_show(border);
|
||||
|
||||
button = evisum_ui_button_add(parent, &ui->btn_stop, _("Stop"),
|
||||
button = evisum_ui_tab_add(parent, &ui->btn_stop, _("Stop"),
|
||||
_btn_stop_clicked_cb, ui);
|
||||
ui->btn_stop = button;
|
||||
elm_object_content_set(border, button);
|
||||
|
@ -611,7 +660,7 @@ _process_tab_add(Evas_Object *parent, Ui_Process *ui)
|
|||
elm_object_style_set(border, "pad_small");
|
||||
evas_object_show(border);
|
||||
|
||||
button = evisum_ui_button_add(parent, &ui->btn_start, _("Start"),
|
||||
button = evisum_ui_tab_add(parent, &ui->btn_start, _("Start"),
|
||||
_btn_start_clicked_cb, ui);
|
||||
ui->btn_start = button;
|
||||
elm_object_content_set(border, button);
|
||||
|
@ -623,7 +672,7 @@ _process_tab_add(Evas_Object *parent, Ui_Process *ui)
|
|||
elm_object_style_set(border, "pad_small");
|
||||
evas_object_show(border);
|
||||
|
||||
button = evisum_ui_button_add(parent, &ui->btn_kill, _("Kill"),
|
||||
button = evisum_ui_tab_add(parent, &ui->btn_kill, _("Kill"),
|
||||
_btn_kill_clicked_cb, ui);
|
||||
ui->btn_kill = button;
|
||||
elm_object_content_set(border, button);
|
||||
|
@ -643,7 +692,7 @@ _btn_icon_state_set(Evas_Object *button, Eina_Bool reverse)
|
|||
elm_icon_standard_set(icon, evisum_icon_path_get("go-up"));
|
||||
|
||||
elm_object_part_content_set(button, "icon", icon);
|
||||
evas_object_color_set(icon, 47, 153, 255, 255);
|
||||
evas_object_color_set(icon, 255, 255, 255, 255);
|
||||
|
||||
evas_object_show(icon);
|
||||
}
|
||||
|
@ -717,12 +766,19 @@ static Evas_Object *
|
|||
_threads_tab_add(Evas_Object *parent, Ui_Process *ui)
|
||||
{
|
||||
Evas_Object *frame, *box, *hbox, *btn, *genlist;
|
||||
int r, g, b, a;
|
||||
|
||||
frame = elm_frame_add(parent);
|
||||
evas_object_size_hint_weight_set(frame, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(frame, FILL, FILL);
|
||||
elm_object_text_set(frame, _("Threads"));
|
||||
|
||||
if (evisum_ui_effects_enabled_get())
|
||||
{
|
||||
evas_object_color_get(frame, &r, &g, &b, &a);
|
||||
evas_object_color_set(frame, r * 0.75, g * 0.75, b * 0.75, a * 0.75);
|
||||
}
|
||||
|
||||
box = elm_box_add(parent);
|
||||
evas_object_size_hint_weight_set(box, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(box, FILL, FILL);
|
||||
|
@ -786,6 +842,7 @@ _threads_tab_add(Evas_Object *parent, Ui_Process *ui)
|
|||
evas_object_data_set(genlist, "ui", ui);
|
||||
elm_object_focus_allow_set(genlist, EINA_FALSE);
|
||||
elm_genlist_homogeneous_set(genlist, EINA_TRUE);
|
||||
elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_NONE);
|
||||
evas_object_size_hint_weight_set(genlist, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(genlist, FILL, FILL);
|
||||
evas_object_show(genlist);
|
||||
|
@ -803,12 +860,19 @@ static Evas_Object *
|
|||
_info_tab_add(Evas_Object *parent, Ui_Process *ui)
|
||||
{
|
||||
Evas_Object *frame, *box, *entry;
|
||||
int r, g, b, a;
|
||||
|
||||
frame = elm_frame_add(parent);
|
||||
evas_object_size_hint_weight_set(frame, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(frame, FILL, FILL);
|
||||
elm_object_text_set(frame, _("Documentation"));
|
||||
|
||||
if (evisum_ui_effects_enabled_get())
|
||||
{
|
||||
evas_object_color_get(frame, &r, &g, &b, &a);
|
||||
evas_object_color_set(frame, r * 0.75, g * 0.75, b * 0.75, a * 0.75);
|
||||
}
|
||||
|
||||
box = elm_box_add(parent);
|
||||
evas_object_size_hint_weight_set(box, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(box, FILL, FILL);
|
||||
|
@ -870,9 +934,7 @@ _btn_info_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui_Process *ui;
|
||||
char *line;
|
||||
Eina_Strbuf *buf;
|
||||
int n;
|
||||
Eina_List *lines = NULL;
|
||||
|
||||
ui = data;
|
||||
|
||||
|
@ -881,11 +943,27 @@ _btn_info_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
|
||||
if (ui->info_init) return;
|
||||
|
||||
Eina_List *lines =
|
||||
_exe_response(eina_slstr_printf("man %s | col -b", ui->selected_cmd));
|
||||
if (lines)
|
||||
if (ui->selected_cmd && ui->selected_cmd[0] && !strchr(ui->selected_cmd, ' '))
|
||||
lines =_exe_response(eina_slstr_printf("man %s | col -b", ui->selected_cmd));
|
||||
|
||||
if (!lines)
|
||||
{
|
||||
buf = eina_strbuf_new();
|
||||
// LAZY!!!
|
||||
if (!strcmp(ui->selected_cmd, "evisum"))
|
||||
elm_object_text_set(ui->entry_info, _evisum_docs());
|
||||
else
|
||||
{
|
||||
elm_object_text_set(ui->entry_info,
|
||||
eina_slstr_printf(_("No documentation found for %s."),
|
||||
ui->selected_cmd));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char *line;
|
||||
int n = 1;
|
||||
Eina_Strbuf *buf = eina_strbuf_new();
|
||||
|
||||
eina_strbuf_append(buf, "<code>");
|
||||
|
||||
n = 1;
|
||||
|
@ -899,12 +977,6 @@ _btn_info_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
elm_object_text_set(ui->entry_info, eina_strbuf_string_get(buf));
|
||||
eina_strbuf_free(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
elm_object_text_set(ui->entry_info,
|
||||
eina_slstr_printf(_("No documentation found for %s."),
|
||||
ui->selected_cmd));
|
||||
}
|
||||
|
||||
ui->info_init = EINA_TRUE;
|
||||
}
|
||||
|
@ -981,6 +1053,7 @@ _win_del_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
ui = data;
|
||||
win = obj;
|
||||
|
||||
|
||||
if (ui->hash_cpu_times)
|
||||
eina_hash_free(ui->hash_cpu_times);
|
||||
if (ui->timer_pid)
|
||||
|
@ -990,6 +1063,8 @@ _win_del_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
if (ui->cache)
|
||||
evisum_ui_item_cache_free(ui->cache);
|
||||
|
||||
eina_lock_free(&_lock);
|
||||
|
||||
evas_object_del(win);
|
||||
|
||||
free(ui);
|
||||
|
@ -1003,7 +1078,7 @@ _win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
}
|
||||
|
||||
void
|
||||
ui_process_win_add(Evas_Object *parent_win, int pid, const char *cmd)
|
||||
ui_process_win_add(Evas_Object *parent_win, int pid, const char *cmd, int poll_delay)
|
||||
{
|
||||
Evas_Object *win, *ic, *box, *tabs;
|
||||
Evas_Coord x, y, w, h;
|
||||
|
@ -1011,7 +1086,7 @@ ui_process_win_add(Evas_Object *parent_win, int pid, const char *cmd)
|
|||
Ui_Process *ui = calloc(1, sizeof(Ui_Process));
|
||||
ui->selected_pid = pid;
|
||||
ui->selected_cmd = strdup(cmd);
|
||||
ui->poll_delay = 3;
|
||||
ui->poll_delay = poll_delay;
|
||||
ui->cache = NULL;
|
||||
ui->sort_reverse = EINA_TRUE;
|
||||
ui->sort_cb = _sort_by_cpu_usage;
|
||||
|
@ -1023,6 +1098,8 @@ ui_process_win_add(Evas_Object *parent_win, int pid, const char *cmd)
|
|||
elm_win_icon_object_set(win, ic);
|
||||
tabs = _tabs_add(win, ui);
|
||||
|
||||
evisum_ui_background_random_add(win, evisum_ui_effects_enabled_get());
|
||||
|
||||
box = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(box, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(box, FILL, FILL);
|
||||
|
@ -1059,6 +1136,8 @@ ui_process_win_add(Evas_Object *parent_win, int pid, const char *cmd)
|
|||
|
||||
ui->cache = evisum_ui_item_cache_new(ui->genlist_threads, _item_create, 10);
|
||||
|
||||
eina_lock_new(&_lock);
|
||||
|
||||
_proc_info_update(ui);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ typedef struct _Ui_Process {
|
|||
Evas_Object *entry_pid_cmd_args;
|
||||
Evas_Object *entry_pid_user;
|
||||
Evas_Object *entry_pid_pid;
|
||||
Evas_Object *entry_pid_ppid;
|
||||
Evas_Object *entry_pid_uid;
|
||||
Evas_Object *entry_pid_cpu;
|
||||
Evas_Object *entry_pid_threads;
|
||||
|
@ -32,6 +33,7 @@ typedef struct _Ui_Process {
|
|||
Evas_Object *entry_pid_rss;
|
||||
Evas_Object *entry_pid_shared;
|
||||
Evas_Object *entry_pid_size;
|
||||
Evas_Object *entry_pid_started;
|
||||
Evas_Object *entry_pid_nice;
|
||||
Evas_Object *entry_pid_pri;
|
||||
Evas_Object *entry_pid_state;
|
||||
|
@ -62,6 +64,6 @@ typedef struct _Ui_Process {
|
|||
} Ui_Process;
|
||||
|
||||
void
|
||||
ui_process_win_add(Evas_Object *parent_win, int pid, const char *cmd);
|
||||
ui_process_win_add(Evas_Object *parent_win, int pid, const char *cmd, int poll_delay);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
#include <Elementary.h>
|
||||
#include "config.h"
|
||||
|
||||
#define ARRAY_SIZE(n) sizeof(n) / sizeof(n[0])
|
||||
|
||||
static Eina_Bool _effects_enabled = EINA_FALSE;
|
||||
|
||||
Evas_Object *
|
||||
evisum_ui_tab_add(Evas_Object *parent, Evas_Object **alias, const char *text,
|
||||
Evas_Smart_Cb clicked_cb, void *data)
|
||||
|
@ -45,9 +49,9 @@ evisum_ui_tab_add(Evas_Object *parent, Evas_Object **alias, const char *text,
|
|||
|
||||
Evas_Object *
|
||||
evisum_ui_button_add(Evas_Object *parent, Evas_Object **alias, const char *text,
|
||||
Evas_Smart_Cb clicked_cb, void *data)
|
||||
const char *icon, Evas_Smart_Cb clicked_cb, void *data)
|
||||
{
|
||||
Evas_Object *tbl, *rect, *button, *label;
|
||||
Evas_Object *tbl, *rect, *button, *label, *hbx, *ic;
|
||||
|
||||
tbl = elm_table_add(parent);
|
||||
evas_object_size_hint_weight_set(tbl, EXPAND, EXPAND);
|
||||
|
@ -66,13 +70,29 @@ evisum_ui_button_add(Evas_Object *parent, Evas_Object **alias, const char *text,
|
|||
evas_object_show(button);
|
||||
evas_object_smart_callback_add(button, "clicked", clicked_cb, data);
|
||||
|
||||
hbx = elm_box_add(parent);
|
||||
elm_box_horizontal_set(hbx, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(hbx, 0.0, EXPAND);
|
||||
evas_object_size_hint_align_set(hbx, FILL, FILL);
|
||||
evas_object_show(hbx);
|
||||
|
||||
ic = elm_icon_add(parent);
|
||||
elm_icon_standard_set(ic, evisum_icon_path_get(icon));
|
||||
evas_object_size_hint_weight_set(ic, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(ic, FILL, FILL);
|
||||
evas_object_show(ic);
|
||||
|
||||
elm_box_pack_end(hbx, ic);
|
||||
|
||||
label = elm_label_add(parent);
|
||||
evas_object_size_hint_weight_set(label, EXPAND, EXPAND);
|
||||
evas_object_size_hint_weight_set(label, 1.0, EXPAND);
|
||||
evas_object_size_hint_align_set(label, FILL, FILL);
|
||||
evas_object_show(label);
|
||||
elm_object_text_set(label,
|
||||
eina_slstr_printf("%s", text));
|
||||
elm_layout_content_set(button, "elm.swallow.content", label);
|
||||
|
||||
elm_box_pack_end(hbx, label);
|
||||
elm_layout_content_set(button, "elm.swallow.content", hbx);
|
||||
|
||||
elm_table_pack(tbl, rect, 0, 0, 1, 1);
|
||||
elm_table_pack(tbl, button, 0, 0, 1, 1);
|
||||
|
@ -209,10 +229,14 @@ evisum_child_window_show(Evas_Object *parent, Evas_Object *win)
|
|||
typedef struct {
|
||||
Ui *ui;
|
||||
Evas_Object *label;
|
||||
Evas_Object *win;
|
||||
Evas_Object *version;
|
||||
Evas_Object *bg;
|
||||
Evas_Object *im;
|
||||
Ecore_Animator *animator;
|
||||
int pos;
|
||||
int pos2;
|
||||
Eina_Bool im_upwards;
|
||||
} Animate_Data;
|
||||
|
||||
static void
|
||||
|
@ -234,15 +258,28 @@ _win_del_cb(void *data, Evas_Object *obj,
|
|||
ui->win_about = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_about_resize_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Animate_Data *ad = data;
|
||||
|
||||
evas_object_hide(ad->label);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
about_anim(void *data)
|
||||
{
|
||||
Animate_Data *ad;
|
||||
Evas_Coord w, h, ow, oh, x;
|
||||
Evas_Coord ix, iy, iw, ih;
|
||||
static Eina_Bool begin = 0;
|
||||
time_t t = time(NULL);
|
||||
|
||||
ad = data;
|
||||
|
||||
evas_object_geometry_get(ad->bg, NULL, NULL, &w, &h);
|
||||
evas_object_geometry_get(ad->bg, NULL, NULL, &w, &h);
|
||||
if (w <= 0 || h <= 0) return EINA_TRUE;
|
||||
evas_object_geometry_get(ad->label, &x, NULL, &ow, &oh);
|
||||
evas_object_move(ad->label, x, ad->pos);
|
||||
evas_object_show(ad->label);
|
||||
|
@ -250,6 +287,34 @@ about_anim(void *data)
|
|||
ad->pos--;
|
||||
if (ad->pos <= -oh) ad->pos = h;
|
||||
|
||||
if (!(t % 20)) begin = 1;
|
||||
|
||||
if (!begin) return EINA_TRUE;
|
||||
|
||||
evas_object_geometry_get(ad->im, &ix, &iy, &iw, &ih);
|
||||
|
||||
if (ad->im_upwards)
|
||||
ad->pos2 -= 1;
|
||||
else
|
||||
ad->pos2 += 5;
|
||||
|
||||
evas_object_move(ad->im, ix, ad->pos2);
|
||||
evas_object_show(ad->im);
|
||||
|
||||
if (ad->pos2 < ih)
|
||||
{
|
||||
ad->im_upwards = 0;
|
||||
}
|
||||
else if (ad->pos2 > h + ih)
|
||||
{
|
||||
ad->pos2 = (h + ih);
|
||||
ad->im_upwards = 1;
|
||||
srand(t);
|
||||
evas_object_move(ad->im, rand() % w, ad->pos2);
|
||||
evas_object_hide(ad->im);
|
||||
begin = 0;
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
@ -258,7 +323,9 @@ evisum_about_window_show(void *data)
|
|||
{
|
||||
Ui *ui;
|
||||
Animate_Data *about;
|
||||
Evas_Object *win, *bg, *box, *version, *label, *btn;
|
||||
Evas_Object *win, *bg, *box, *version, *label, *btn, *im;
|
||||
Evas_Coord x, y, w, h;
|
||||
Evas_Coord iw, ih;
|
||||
const char *copyright =
|
||||
"<font color=#ffffff>"
|
||||
"<small>"
|
||||
|
@ -286,7 +353,7 @@ evisum_about_window_show(void *data)
|
|||
|
||||
if (ui->win_about) return;
|
||||
|
||||
ui->win_about = win = elm_win_add(ui->win, "evisum", ELM_WIN_DIALOG_BASIC);
|
||||
ui->win_about = win = elm_win_add(ui->win, "evisum", ELM_WIN_BASIC);
|
||||
elm_win_title_set(win, "About Evisum");
|
||||
|
||||
bg = elm_bg_add(win);
|
||||
|
@ -294,7 +361,6 @@ evisum_about_window_show(void *data)
|
|||
evas_object_size_hint_align_set(bg, FILL, FILL);
|
||||
elm_bg_file_set(bg, evisum_icon_path_get("ladyhand"), NULL);
|
||||
elm_win_resize_object_add(win, bg);
|
||||
evas_object_color_set(bg, 160, 160, 160, 255);
|
||||
evas_object_show(bg);
|
||||
evas_object_size_hint_min_set(bg, 320 * elm_config_scale_get(),
|
||||
320 * elm_config_scale_get());
|
||||
|
@ -302,7 +368,6 @@ evisum_about_window_show(void *data)
|
|||
box = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(box, EXPAND, EXPAND);
|
||||
evas_object_size_hint_align_set(box, FILL, FILL);
|
||||
evas_object_color_set(box, 255, 255, 255, 255);
|
||||
evas_object_show(box);
|
||||
|
||||
label = elm_label_add(win);
|
||||
|
@ -314,22 +379,37 @@ evisum_about_window_show(void *data)
|
|||
eina_slstr_printf("<font color=#ffffff><b>%s</b>",
|
||||
PACKAGE_VERSION));
|
||||
|
||||
evas_object_geometry_get(win, &x, &y, &w, &h);
|
||||
|
||||
im = evas_object_image_filled_add(evas_object_evas_get(bg));
|
||||
evas_object_image_file_set(im, evisum_icon_path_get("lovethisdogharvey"), NULL);
|
||||
evas_object_image_size_get(im, &iw, &ih);
|
||||
evas_object_size_hint_min_set(im, iw, ih);
|
||||
evas_object_resize(im, iw, ih);
|
||||
evas_object_move(im, iw / 3, h + ih + ih);
|
||||
evas_object_pass_events_set(im, 1);
|
||||
|
||||
about = malloc(sizeof(Animate_Data));
|
||||
about->win = win;
|
||||
about->bg = bg;
|
||||
about->label = label;
|
||||
about->version = version;
|
||||
about->pos = elm_config_scale_get() * 320;
|
||||
about->ui = ui;
|
||||
about->im = im;
|
||||
about->pos2 = h + ih + ih;
|
||||
about->im_upwards = 1;
|
||||
about->animator = ecore_animator_add(about_anim, about);
|
||||
|
||||
btn = elm_button_add(win);
|
||||
evas_object_size_hint_align_set(btn, 0.5, 0.9);
|
||||
evas_object_size_hint_weight_set(btn, EXPAND, EXPAND);
|
||||
elm_object_text_set(btn, _("Okay!"));
|
||||
elm_object_text_set(btn, _("Close"));
|
||||
evas_object_show(btn);
|
||||
|
||||
evas_object_smart_callback_add(btn, "clicked", _win_del_cb, about);
|
||||
evas_object_smart_callback_add(win, "delete,request", _win_del_cb, about);
|
||||
evas_object_smart_callback_add(win, "resize", _about_resize_cb, about);
|
||||
|
||||
elm_box_pack_end(box, version);
|
||||
elm_box_pack_end(box, label);
|
||||
|
@ -338,3 +418,183 @@ evisum_about_window_show(void *data)
|
|||
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
||||
const char *
|
||||
evisum_image_path_get(const char *name)
|
||||
{
|
||||
char *path;
|
||||
const char *icon_path = NULL, *directory = PACKAGE_DATA_DIR "/images";
|
||||
|
||||
path = _path_append(directory, eina_slstr_printf("%s.jpg", name));
|
||||
if (path)
|
||||
{
|
||||
if (ecore_file_exists(path))
|
||||
icon_path = eina_slstr_printf("%s", path);
|
||||
|
||||
free(path);
|
||||
}
|
||||
|
||||
return icon_path;
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
evisum_ui_background_random_add(Evas_Object *win, Eina_Bool enabled)
|
||||
{
|
||||
Evas_Object *bg;
|
||||
int i;
|
||||
char *images[] = { "sky_01", "sky_02", "sky_03", "sky_04" };
|
||||
|
||||
if (!enabled) return NULL;
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
i = rand() % ARRAY_SIZE(images);
|
||||
|
||||
bg = elm_bg_add(win);
|
||||
elm_bg_file_set(bg, evisum_image_path_get(images[i]), NULL);
|
||||
evas_object_size_hint_align_set(bg, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(bg, EXPAND, EXPAND);
|
||||
elm_win_resize_object_add(win, bg);
|
||||
evas_object_show(bg);
|
||||
|
||||
return bg;
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
evisum_ui_background_add(Evas_Object *win, Eina_Bool enabled)
|
||||
{
|
||||
Evas_Object *bg;
|
||||
|
||||
if (!enabled) return NULL;
|
||||
|
||||
bg = elm_bg_add(win);
|
||||
elm_bg_file_set(bg, evisum_image_path_get("sky_03"), NULL);
|
||||
evas_object_size_hint_align_set(bg, FILL, FILL);
|
||||
evas_object_size_hint_weight_set(bg, EXPAND, EXPAND);
|
||||
elm_win_resize_object_add(win, bg);
|
||||
evas_object_show(bg);
|
||||
|
||||
return bg;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
evisum_ui_effects_enabled_get(void)
|
||||
{
|
||||
return _effects_enabled;
|
||||
}
|
||||
|
||||
void
|
||||
evisum_ui_effects_enabled_set(Eina_Bool enabled)
|
||||
{
|
||||
_effects_enabled = enabled;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Ui *ui;
|
||||
int pos;
|
||||
Evas_Object *im;
|
||||
Evas_Object *bolt;
|
||||
} Animation;
|
||||
|
||||
static Eina_Bool
|
||||
_anim_clouds(void *data)
|
||||
{
|
||||
Ui *ui;
|
||||
Animation *anim;
|
||||
Evas_Coord ww, wh, iw, ih;
|
||||
int cpu;
|
||||
time_t t;
|
||||
static int bolt = 0;
|
||||
|
||||
anim = data;
|
||||
ui = anim->ui;
|
||||
|
||||
evas_object_geometry_get(ui->win, NULL, NULL, &ww, &wh);
|
||||
if (ww <= 0 || wh <= 0) return EINA_TRUE;
|
||||
evas_object_image_size_get(anim->im, &iw, &ih);
|
||||
|
||||
if (ww > iw) iw = ww;
|
||||
|
||||
cpu = (ui->cpu_usage / 10) > 0 ? ui->cpu_usage / 10 : 1;
|
||||
|
||||
evas_object_resize(anim->im, iw, wh);
|
||||
evas_object_image_fill_set(anim->im, anim->pos, -50, iw, ih);
|
||||
anim->pos += cpu;
|
||||
|
||||
t = time(NULL);
|
||||
|
||||
if (cpu >= 6 && !bolt)
|
||||
{
|
||||
if (cpu == 6 && !(t % 16)) bolt++;
|
||||
else if (cpu == 7 && !(t % 8)) bolt++;
|
||||
else if (cpu == 8 && !(t % 4)) bolt++;
|
||||
else if (cpu == 9 && !(t % 2)) bolt++;
|
||||
else if (cpu == 10) bolt++;
|
||||
}
|
||||
|
||||
if (bolt)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
if (bolt++ == 1)
|
||||
{
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
srand(ts.tv_nsec);
|
||||
evas_object_image_size_get(anim->bolt, &iw, &ih);
|
||||
evas_object_move(anim->bolt, -(rand() % iw), -(rand() % (ih / 4)));
|
||||
}
|
||||
|
||||
if (bolt > 20)
|
||||
{
|
||||
evas_object_hide(anim->bolt);
|
||||
bolt = 0;
|
||||
}
|
||||
else if (!(bolt % 2))
|
||||
evas_object_show(anim->bolt);
|
||||
else
|
||||
evas_object_hide(anim->bolt);
|
||||
}
|
||||
|
||||
if (anim->pos >= iw)
|
||||
anim->pos = 0;
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
void
|
||||
evisum_ui_animate(void *data)
|
||||
{
|
||||
Animation *anim;
|
||||
Ui *ui;
|
||||
Evas_Object *im;
|
||||
Evas_Coord iw, ih, ww, wh;
|
||||
|
||||
ui = data;
|
||||
|
||||
anim = calloc(1, sizeof(Animation));
|
||||
if (!anim) return;
|
||||
|
||||
anim->ui = ui;
|
||||
|
||||
evas_object_geometry_get(ui->win, NULL, NULL, &ww, &wh);
|
||||
|
||||
anim->bolt = im = evas_object_image_filled_add(evas_object_evas_get(ui->win));
|
||||
evas_object_pass_events_set(im, 1);
|
||||
evas_object_image_file_set(im, evisum_icon_path_get("bolt"), NULL);
|
||||
evas_object_image_size_get(im, &iw, &ih);
|
||||
evas_object_size_hint_min_set(im, iw, ih);
|
||||
evas_object_resize(im, iw, ih);
|
||||
|
||||
anim->im = im = evas_object_image_add(evas_object_evas_get(ui->win));
|
||||
evas_object_image_file_set(im, evisum_icon_path_get("clo"), NULL);
|
||||
evas_object_image_size_get(im, &iw, &ih);
|
||||
evas_object_image_fill_set(im, 0, -50, iw, wh);
|
||||
evas_object_resize(im, iw, wh);
|
||||
evas_object_move(im, 0, 0);
|
||||
evas_object_pass_events_set(im, 1);
|
||||
evas_object_show(im);
|
||||
|
||||
ui->animator = ecore_animator_add(_anim_clouds, anim);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#define FILL EVAS_HINT_FILL
|
||||
#define EXPAND EVAS_HINT_EXPAND
|
||||
|
||||
#define TAB_BTN_WIDTH 96
|
||||
#define TAB_BTN_HEIGHT 32
|
||||
#define TAB_BTN_WIDTH 84
|
||||
#define TAB_BTN_HEIGHT 28
|
||||
#define BTN_WIDTH 80
|
||||
#define BTN_HEIGHT 24
|
||||
|
||||
|
@ -20,11 +20,11 @@
|
|||
|
||||
Evas_Object *
|
||||
evisum_ui_tab_add(Evas_Object *parent, Evas_Object **alias, const char *text,
|
||||
Evas_Smart_Cb clicked_cb, void *data);
|
||||
Evas_Smart_Cb clicked_cb, void *data);
|
||||
|
||||
Evas_Object *
|
||||
evisum_ui_button_add(Evas_Object *parent, Evas_Object **alias, const char *text,
|
||||
Evas_Smart_Cb clicked_cb, void *data);
|
||||
const char *icon, Evas_Smart_Cb clicked_cb, void *data);
|
||||
|
||||
const char *
|
||||
evisum_size_format(unsigned long long bytes);
|
||||
|
@ -32,6 +32,24 @@ evisum_size_format(unsigned long long bytes);
|
|||
const char *
|
||||
evisum_icon_path_get(const char *name);
|
||||
|
||||
const char *
|
||||
evisum_image_path_get(const char *name);
|
||||
|
||||
Evas_Object *
|
||||
evisum_ui_background_add(Evas_Object *win, Eina_Bool enabled);
|
||||
|
||||
Evas_Object *
|
||||
evisum_ui_background_random_add(Evas_Object *win, Eina_Bool enabled);
|
||||
|
||||
void
|
||||
evisum_ui_effects_enabled_set(Eina_Bool enabled);
|
||||
|
||||
Eina_Bool
|
||||
evisum_ui_effects_enabled_get(void);
|
||||
|
||||
void
|
||||
evisum_ui_animate(void *data);
|
||||
|
||||
int
|
||||
evisum_ui_textblock_font_size_get(Evas_Object *tb);
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
// Process Window includes this junk.
|
||||
|
||||
static char *
|
||||
_man2entry(const char *text)
|
||||
{
|
||||
|
@ -50,3 +52,14 @@ _man2entry(const char *text)
|
|||
|
||||
return str;
|
||||
}
|
||||
|
||||
static const char *
|
||||
_evisum_docs(void)
|
||||
{
|
||||
const char *txt =
|
||||
"<b>Congratulations you found the documentation!</b><br><br>"
|
||||
"Control + K - Toggle kernel threads. <br>"
|
||||
"Control + E - Show Self. <br>";
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
|