2020-06-21 06:03:39 -07:00
|
|
|
#include "ui_util.h"
|
2020-06-29 07:18:35 -07:00
|
|
|
#include "ui.h"
|
2020-06-21 06:03:39 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "config.h"
|
|
|
|
|
2020-08-30 16:36:00 -07:00
|
|
|
#define ARRAY_SIZE(n) sizeof(n) / sizeof(n[0])
|
|
|
|
|
|
|
|
static Eina_Bool _effects_enabled = EINA_FALSE;
|
2020-10-10 06:52:11 -07:00
|
|
|
static Eina_Bool _backgrounds_enabled = EINA_FALSE;
|
2020-10-29 06:26:31 -07:00
|
|
|
static Eina_Hash *_icon_cache = NULL;
|
2020-08-30 16:36:00 -07:00
|
|
|
|
2020-06-21 06:03:39 -07:00
|
|
|
Evas_Object *
|
2020-06-21 09:14:35 -07:00
|
|
|
evisum_ui_tab_add(Evas_Object *parent, Evas_Object **alias, const char *text,
|
2020-06-21 06:03:39 -07:00
|
|
|
Evas_Smart_Cb clicked_cb, void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *tbl, *rect, *button, *label;
|
|
|
|
|
|
|
|
tbl = elm_table_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(tbl, EXPAND, EXPAND);
|
|
|
|
evas_object_size_hint_align_set(tbl, FILL, FILL);
|
|
|
|
|
|
|
|
rect = evas_object_rectangle_add(tbl);
|
|
|
|
evas_object_size_hint_weight_set(rect, EXPAND, EXPAND);
|
|
|
|
evas_object_size_hint_align_set(rect, FILL, FILL);
|
|
|
|
evas_object_size_hint_min_set(rect,
|
|
|
|
TAB_BTN_WIDTH * elm_config_scale_get(),
|
|
|
|
TAB_BTN_HEIGHT * elm_config_scale_get());
|
|
|
|
|
|
|
|
button = elm_button_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(button, EXPAND, EXPAND);
|
|
|
|
evas_object_size_hint_align_set(button, FILL, FILL);
|
|
|
|
evas_object_show(button);
|
|
|
|
evas_object_smart_callback_add(button, "clicked", clicked_cb, data);
|
|
|
|
|
|
|
|
label = elm_label_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(label, EXPAND, EXPAND);
|
|
|
|
evas_object_size_hint_align_set(label, FILL, FILL);
|
|
|
|
evas_object_show(label);
|
|
|
|
elm_object_text_set(label,
|
2020-06-29 14:15:21 -07:00
|
|
|
eina_slstr_printf("%s", text));
|
2020-06-21 06:03:39 -07:00
|
|
|
elm_layout_content_set(button, "elm.swallow.content", label);
|
|
|
|
|
|
|
|
elm_table_pack(tbl, rect, 0, 0, 1, 1);
|
|
|
|
elm_table_pack(tbl, button, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
if (alias)
|
|
|
|
*alias = button;
|
|
|
|
|
|
|
|
return tbl;
|
|
|
|
}
|
|
|
|
|
2020-06-21 09:14:35 -07:00
|
|
|
Evas_Object *
|
|
|
|
evisum_ui_button_add(Evas_Object *parent, Evas_Object **alias, const char *text,
|
2020-08-19 11:11:54 -07:00
|
|
|
const char *icon, Evas_Smart_Cb clicked_cb, void *data)
|
2020-06-21 09:14:35 -07:00
|
|
|
{
|
2020-08-19 11:11:54 -07:00
|
|
|
Evas_Object *tbl, *rect, *button, *label, *hbx, *ic;
|
2020-06-21 09:14:35 -07:00
|
|
|
|
|
|
|
tbl = elm_table_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(tbl, EXPAND, EXPAND);
|
|
|
|
evas_object_size_hint_align_set(tbl, FILL, FILL);
|
|
|
|
|
|
|
|
rect = evas_object_rectangle_add(tbl);
|
|
|
|
evas_object_size_hint_weight_set(rect, EXPAND, EXPAND);
|
|
|
|
evas_object_size_hint_align_set(rect, FILL, FILL);
|
|
|
|
evas_object_size_hint_min_set(rect,
|
|
|
|
BTN_WIDTH * elm_config_scale_get(),
|
|
|
|
BTN_HEIGHT * elm_config_scale_get());
|
|
|
|
|
|
|
|
button = elm_button_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(button, EXPAND, EXPAND);
|
|
|
|
evas_object_size_hint_align_set(button, FILL, FILL);
|
|
|
|
evas_object_show(button);
|
|
|
|
evas_object_smart_callback_add(button, "clicked", clicked_cb, data);
|
|
|
|
|
2020-08-19 11:11:54 -07:00
|
|
|
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);
|
|
|
|
|
2020-06-21 09:14:35 -07:00
|
|
|
label = elm_label_add(parent);
|
2020-08-19 11:11:54 -07:00
|
|
|
evas_object_size_hint_weight_set(label, 1.0, EXPAND);
|
2020-06-21 09:14:35 -07:00
|
|
|
evas_object_size_hint_align_set(label, FILL, FILL);
|
|
|
|
evas_object_show(label);
|
|
|
|
elm_object_text_set(label,
|
|
|
|
eina_slstr_printf("%s", text));
|
2020-08-19 11:11:54 -07:00
|
|
|
|
|
|
|
elm_box_pack_end(hbx, label);
|
|
|
|
elm_layout_content_set(button, "elm.swallow.content", hbx);
|
2020-06-21 09:14:35 -07:00
|
|
|
|
|
|
|
elm_table_pack(tbl, rect, 0, 0, 1, 1);
|
|
|
|
elm_table_pack(tbl, button, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
if (alias)
|
|
|
|
*alias = button;
|
|
|
|
|
|
|
|
return tbl;
|
|
|
|
}
|
|
|
|
|
2020-06-21 06:03:39 -07:00
|
|
|
const char *
|
|
|
|
evisum_size_format(unsigned long long bytes)
|
|
|
|
{
|
|
|
|
const char *s, *unit = "BKMGTPEZY";
|
|
|
|
unsigned long powi = 1;
|
|
|
|
unsigned long long value;
|
|
|
|
unsigned int precision = 2, powj = 1;
|
|
|
|
|
|
|
|
value = bytes;
|
|
|
|
while (value > 1024)
|
|
|
|
{
|
|
|
|
if ((value / 1024) < powi) break;
|
|
|
|
powi *= 1024;
|
|
|
|
++unit;
|
|
|
|
if (unit[1] == '\0') break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*unit == 'B') precision = 0;
|
|
|
|
|
|
|
|
while (precision > 0)
|
|
|
|
{
|
|
|
|
powj *= 10;
|
|
|
|
if ((value / powi) < powj) break;
|
|
|
|
--precision;
|
|
|
|
}
|
|
|
|
|
|
|
|
s = eina_slstr_printf("%1.*f %c", precision, (double) value / powi, *unit);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_path_append(const char *path, const char *file)
|
|
|
|
{
|
|
|
|
char *concat;
|
|
|
|
int len;
|
|
|
|
char separator = '/';
|
|
|
|
|
|
|
|
len = strlen(path) + strlen(file) + 2;
|
|
|
|
concat = malloc(len * sizeof(char));
|
|
|
|
snprintf(concat, len, "%s%c%s", path, separator, file);
|
|
|
|
|
|
|
|
return concat;
|
|
|
|
}
|
|
|
|
|
2020-10-29 06:26:31 -07:00
|
|
|
void
|
|
|
|
_icon_cache_free_cb(void *data)
|
|
|
|
{
|
|
|
|
char *ic_name = data;
|
|
|
|
|
|
|
|
free(ic_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evisum_icon_cache_init(void)
|
|
|
|
{
|
|
|
|
_icon_cache = eina_hash_string_superfast_new(_icon_cache_free_cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evisum_icon_cache_shutdown(void)
|
|
|
|
{
|
|
|
|
eina_hash_free(_icon_cache);
|
|
|
|
}
|
|
|
|
|
2020-11-16 17:14:12 -08:00
|
|
|
|
2020-10-29 06:26:31 -07:00
|
|
|
const char *
|
2020-11-16 17:14:12 -08:00
|
|
|
evisum_icon_cache_find(const Proc_Info *proc)
|
2020-10-29 06:26:31 -07:00
|
|
|
{
|
|
|
|
Efreet_Desktop *e;
|
2020-11-16 17:14:12 -08:00
|
|
|
const char *name, *cmd;
|
2020-10-29 06:26:31 -07:00
|
|
|
char *exists;
|
|
|
|
|
2020-11-16 17:14:12 -08:00
|
|
|
if (proc->is_kernel)
|
|
|
|
#if defined(__linux__)
|
|
|
|
return "linux";
|
|
|
|
#else
|
|
|
|
return "freebsd;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
cmd = proc->command;
|
|
|
|
|
2020-10-29 06:26:31 -07:00
|
|
|
exists = eina_hash_find(_icon_cache, cmd);
|
|
|
|
if (exists) return exists;
|
|
|
|
|
|
|
|
if (!strncmp(cmd, "enlightenment", 13)) return "e";
|
|
|
|
|
|
|
|
e = efreet_util_desktop_exec_find(cmd);
|
|
|
|
if (!e)
|
|
|
|
return "application";
|
|
|
|
|
|
|
|
if (e->icon)
|
|
|
|
name = e->icon;
|
|
|
|
else
|
|
|
|
name = cmd;
|
|
|
|
|
|
|
|
eina_hash_add(_icon_cache, cmd, strdup(name));
|
|
|
|
|
|
|
|
efreet_desktop_free(e);
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2020-06-21 06:03:39 -07:00
|
|
|
const char *
|
|
|
|
evisum_icon_path_get(const char *name)
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
const char *icon_path, *directory = PACKAGE_DATA_DIR "/images";
|
|
|
|
icon_path = name;
|
|
|
|
|
|
|
|
path = _path_append(directory, eina_slstr_printf("%s.png", name));
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
if (ecore_file_exists(path))
|
|
|
|
icon_path = eina_slstr_printf("%s", path);
|
|
|
|
|
|
|
|
free(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
return icon_path;
|
|
|
|
}
|
|
|
|
|
2020-06-21 07:30:34 -07:00
|
|
|
void
|
|
|
|
evisum_ui_textblock_font_size_set(Evas_Object *tb, int new_size)
|
|
|
|
{
|
|
|
|
Evas_Textblock_Style *ts;
|
|
|
|
|
|
|
|
if (!tb) return;
|
|
|
|
|
|
|
|
ts = evas_textblock_style_new();
|
|
|
|
|
|
|
|
evas_textblock_style_set(ts,
|
|
|
|
eina_slstr_printf("DEFAULT='font_size=%d'", new_size));
|
|
|
|
evas_object_textblock_style_user_push(tb, ts);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
evisum_ui_textblock_font_size_get(Evas_Object *tb)
|
|
|
|
{
|
|
|
|
const char *style;
|
|
|
|
char *p, *p1;
|
|
|
|
Evas_Textblock_Style *ts;
|
|
|
|
int size = 0;
|
|
|
|
|
|
|
|
if (!tb) return size;
|
|
|
|
|
|
|
|
ts = evas_object_textblock_style_get(tb);
|
|
|
|
if (!ts) return size;
|
|
|
|
|
|
|
|
style = evas_textblock_style_get(ts);
|
|
|
|
if (!style && !style[0]) return size;
|
|
|
|
|
|
|
|
p = strdup(style);
|
|
|
|
|
|
|
|
p1 = strstr(p, "font_size=");
|
|
|
|
if (p1)
|
|
|
|
{
|
|
|
|
p1 += 10;
|
|
|
|
size = atoi(p1);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(p);
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
2020-06-28 12:02:07 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
evisum_child_window_show(Evas_Object *parent, Evas_Object *win)
|
|
|
|
{
|
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
|
|
|
|
evas_object_resize(win, UI_CHILD_WIN_WIDTH, UI_CHILD_WIN_HEIGHT);
|
|
|
|
evas_object_geometry_get(parent, &x, &y, &w, &h);
|
|
|
|
if (x > 0 && y > 0)
|
|
|
|
evas_object_move(win, x + 20, y + 10);
|
|
|
|
else
|
|
|
|
elm_win_center(win, EINA_TRUE, EINA_TRUE);
|
|
|
|
|
|
|
|
evas_object_show(win);
|
|
|
|
}
|
|
|
|
|
2020-06-29 08:05:30 -07:00
|
|
|
typedef struct {
|
2020-07-03 05:20:24 -07:00
|
|
|
Ui *ui;
|
|
|
|
Evas_Object *label;
|
2020-09-04 09:01:40 -07:00
|
|
|
Evas_Object *win;
|
2020-07-03 05:20:24 -07:00
|
|
|
Evas_Object *bg;
|
2020-09-04 09:01:40 -07:00
|
|
|
Evas_Object *im;
|
2020-07-03 05:20:24 -07:00
|
|
|
Ecore_Animator *animator;
|
|
|
|
int pos;
|
2020-09-04 12:05:52 -07:00
|
|
|
int pos2;
|
|
|
|
Eina_Bool im_upwards;
|
2020-06-29 14:23:56 -07:00
|
|
|
} Animate_Data;
|
2020-06-29 08:05:30 -07:00
|
|
|
|
2020-06-29 07:18:35 -07:00
|
|
|
static void
|
2020-11-14 09:45:22 -08:00
|
|
|
_win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
2020-06-29 07:18:35 -07:00
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
2020-07-03 05:20:24 -07:00
|
|
|
Animate_Data *ad;
|
2020-06-29 07:18:35 -07:00
|
|
|
Ui *ui;
|
|
|
|
|
2020-07-03 05:20:24 -07:00
|
|
|
ad = data;
|
|
|
|
ui = ad->ui;
|
|
|
|
|
|
|
|
if (ad->animator)
|
|
|
|
ecore_animator_del(ad->animator);
|
|
|
|
|
|
|
|
free(ad);
|
2020-06-29 07:18:35 -07:00
|
|
|
|
2020-07-03 05:20:24 -07:00
|
|
|
evas_object_del(ui->win_about);
|
2020-06-30 05:05:35 -07:00
|
|
|
ui->win_about = NULL;
|
2020-06-29 07:18:35 -07:00
|
|
|
}
|
|
|
|
|
2020-09-06 16:59:00 -07:00
|
|
|
static void
|
2020-11-14 09:45:22 -08:00
|
|
|
_btn_close_cb(void *data EINA_UNUSED, Evas_Object *obj,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Animate_Data *ad;
|
|
|
|
Ui *ui;
|
|
|
|
|
|
|
|
ad = data;
|
|
|
|
ui = ad->ui;
|
|
|
|
|
|
|
|
evas_object_del(ui->win_about);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_about_resize_cb(void *data, Evas *e, Evas_Object *obj EINA_UNUSED,
|
2020-09-06 16:59:00 -07:00
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Animate_Data *ad = data;
|
|
|
|
|
|
|
|
evas_object_hide(ad->label);
|
|
|
|
}
|
|
|
|
|
2020-06-29 08:05:30 -07:00
|
|
|
static Eina_Bool
|
2020-06-29 14:23:56 -07:00
|
|
|
about_anim(void *data)
|
2020-06-29 08:05:30 -07:00
|
|
|
{
|
2020-06-29 14:23:56 -07:00
|
|
|
Animate_Data *ad;
|
2020-06-29 08:05:30 -07:00
|
|
|
Evas_Coord w, h, ow, oh, x;
|
2020-09-04 12:05:52 -07:00
|
|
|
Evas_Coord ix, iy, iw, ih;
|
|
|
|
static Eina_Bool begin = 0;
|
|
|
|
time_t t = time(NULL);
|
2020-06-29 08:05:30 -07:00
|
|
|
|
2020-06-29 14:23:56 -07:00
|
|
|
ad = data;
|
2020-06-29 08:05:30 -07:00
|
|
|
|
2020-09-04 09:01:40 -07:00
|
|
|
evas_object_geometry_get(ad->bg, NULL, NULL, &w, &h);
|
2020-09-06 05:23:08 -07:00
|
|
|
if (w <= 0 || h <= 0) return EINA_TRUE;
|
2020-06-29 14:23:56 -07:00
|
|
|
evas_object_geometry_get(ad->label, &x, NULL, &ow, &oh);
|
|
|
|
evas_object_move(ad->label, x, ad->pos);
|
2020-07-28 08:11:54 -07:00
|
|
|
evas_object_show(ad->label);
|
2020-06-29 14:23:56 -07:00
|
|
|
|
|
|
|
ad->pos--;
|
2020-10-31 08:44:37 -07:00
|
|
|
|
2020-06-29 14:23:56 -07:00
|
|
|
if (ad->pos <= -oh) ad->pos = h;
|
2020-06-29 08:05:30 -07:00
|
|
|
|
2020-09-04 12:16:16 -07:00
|
|
|
if (!(t % 20)) begin = 1;
|
2020-09-04 12:05:52 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-06-29 08:05:30 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2020-06-29 07:18:35 -07:00
|
|
|
void
|
|
|
|
evisum_about_window_show(void *data)
|
|
|
|
{
|
|
|
|
Ui *ui;
|
2020-07-03 05:20:24 -07:00
|
|
|
Animate_Data *about;
|
2020-10-29 09:43:11 -07:00
|
|
|
Evas_Object *win, *bg, *tbl, *version, *label, *btn, *im;
|
|
|
|
Evas_Object *hbx, *rec, *br;
|
2020-09-04 09:01:40 -07:00
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
Evas_Coord iw, ih;
|
2020-06-29 08:05:30 -07:00
|
|
|
const char *copyright =
|
2020-07-01 06:14:15 -07:00
|
|
|
"<font color=#ffffff>"
|
2020-06-29 14:23:56 -07:00
|
|
|
"<b>"
|
|
|
|
"Copyright © 2019-2020 Alastair Poole <netstar@gmail.com><br>"
|
|
|
|
"<br>"
|
|
|
|
"</b>"
|
2020-06-29 08:05:30 -07:00
|
|
|
"Permission to use, copy, modify, and distribute this software <br>"
|
|
|
|
"for any purpose with or without fee is hereby granted, provided <br>"
|
|
|
|
"that the above copyright notice and this permission notice appear <br>"
|
|
|
|
"in all copies. <br>"
|
|
|
|
"<br>"
|
|
|
|
"THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL <br>"
|
|
|
|
"WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED <br>"
|
|
|
|
"WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL <br>"
|
|
|
|
"THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR <br>"
|
|
|
|
"CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING <br>"
|
|
|
|
"FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF <br>"
|
|
|
|
"CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT <br>"
|
|
|
|
"OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS <br>"
|
2020-10-29 09:43:11 -07:00
|
|
|
"SOFTWARE.<br></></>";
|
2020-06-29 07:18:35 -07:00
|
|
|
|
|
|
|
ui = data;
|
|
|
|
|
2020-06-30 05:05:35 -07:00
|
|
|
if (ui->win_about) return;
|
2020-06-29 08:05:30 -07:00
|
|
|
|
2020-10-29 09:43:11 -07:00
|
|
|
ui->win_about = win = elm_win_add(ui->win, "evisum", ELM_WIN_DIALOG_BASIC);
|
2020-11-14 09:45:22 -08:00
|
|
|
elm_win_autodel_set(win, EINA_TRUE);
|
2020-10-29 09:43:11 -07:00
|
|
|
elm_win_title_set(win, _("About"));
|
|
|
|
|
|
|
|
/* All that moves */
|
2020-06-29 07:18:35 -07:00
|
|
|
|
|
|
|
bg = elm_bg_add(win);
|
|
|
|
evas_object_size_hint_weight_set(bg, EXPAND, EXPAND);
|
|
|
|
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_show(bg);
|
|
|
|
evas_object_size_hint_min_set(bg, 320 * elm_config_scale_get(),
|
|
|
|
320 * elm_config_scale_get());
|
|
|
|
|
2020-10-29 09:43:11 -07:00
|
|
|
tbl = elm_table_add(win);
|
|
|
|
evas_object_show(tbl);
|
|
|
|
elm_win_resize_object_add(tbl, win);
|
|
|
|
elm_table_align_set(tbl, 0, 0);
|
2020-06-29 07:18:35 -07:00
|
|
|
|
2020-06-29 08:05:30 -07:00
|
|
|
label = elm_label_add(win);
|
2020-10-29 09:43:11 -07:00
|
|
|
evas_object_size_hint_align_set(label, 0.0, 0.5);
|
|
|
|
evas_object_size_hint_weight_set(label, EXPAND, 0);
|
2020-09-13 12:27:51 -07:00
|
|
|
elm_object_text_set(label, copyright);
|
2020-06-29 07:18:35 -07:00
|
|
|
|
2020-09-04 09:01:40 -07:00
|
|
|
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);
|
2020-10-31 08:44:37 -07:00
|
|
|
evas_object_size_hint_min_set(im, iw / 2, ih / 2);
|
|
|
|
evas_object_resize(im, iw / 2, ih / 2);
|
2020-09-04 12:05:52 -07:00
|
|
|
evas_object_move(im, iw / 3, h + ih + ih);
|
2020-09-04 09:01:40 -07:00
|
|
|
evas_object_pass_events_set(im, 1);
|
2020-09-04 12:05:52 -07:00
|
|
|
|
2020-07-03 05:20:24 -07:00
|
|
|
about = malloc(sizeof(Animate_Data));
|
2020-09-04 09:01:40 -07:00
|
|
|
about->win = win;
|
2020-07-03 05:20:24 -07:00
|
|
|
about->bg = bg;
|
|
|
|
about->label = label;
|
|
|
|
about->pos = elm_config_scale_get() * 320;
|
|
|
|
about->ui = ui;
|
2020-09-04 09:01:40 -07:00
|
|
|
about->im = im;
|
2020-09-04 12:05:52 -07:00
|
|
|
about->pos2 = h + ih + ih;
|
|
|
|
about->im_upwards = 1;
|
2020-07-03 05:20:24 -07:00
|
|
|
about->animator = ecore_animator_add(about_anim, about);
|
2020-11-14 09:45:22 -08:00
|
|
|
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _win_del_cb, about);
|
|
|
|
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _about_resize_cb, about);
|
2020-10-29 09:43:11 -07:00
|
|
|
|
|
|
|
/* Version overlay */
|
|
|
|
|
|
|
|
hbx = elm_box_add(win);
|
|
|
|
elm_box_horizontal_set(hbx, 1);
|
|
|
|
evas_object_size_hint_align_set(hbx, FILL, 0.5);
|
|
|
|
evas_object_size_hint_weight_set(hbx, EXPAND, 0);
|
|
|
|
evas_object_show(hbx);
|
|
|
|
|
|
|
|
version = elm_label_add(win);
|
|
|
|
evas_object_size_hint_weight_set(version, EXPAND, 0);
|
|
|
|
evas_object_size_hint_align_set(version, 0.1, 0.5);
|
|
|
|
evas_object_show(version);
|
|
|
|
elm_object_text_set(version,
|
2020-10-31 08:44:37 -07:00
|
|
|
eina_slstr_printf("<font color=#ffffff><big>%s</>",
|
2020-10-29 09:43:11 -07:00
|
|
|
PACKAGE_VERSION));
|
|
|
|
|
|
|
|
br = elm_table_add(win);
|
|
|
|
evas_object_size_hint_weight_set(br, EXPAND, 0);
|
|
|
|
evas_object_size_hint_align_set(br, 0.9, 0.5);
|
|
|
|
evas_object_show(br);
|
|
|
|
|
|
|
|
rec = evas_object_rectangle_add(evas_object_evas_get(win));
|
|
|
|
evas_object_size_hint_align_set(rec, FILL, FILL);
|
|
|
|
evas_object_size_hint_weight_set(rec, EXPAND, EXPAND);
|
|
|
|
evas_object_size_hint_min_set(rec, 92, 1);
|
2020-07-03 05:20:24 -07:00
|
|
|
|
2020-06-29 07:18:35 -07:00
|
|
|
btn = elm_button_add(win);
|
2020-10-29 09:43:11 -07:00
|
|
|
evas_object_size_hint_weight_set(btn, EXPAND, 0);
|
|
|
|
evas_object_size_hint_align_set(btn, FILL, FILL);
|
2020-09-04 09:01:40 -07:00
|
|
|
elm_object_text_set(btn, _("Close"));
|
2020-06-29 07:18:35 -07:00
|
|
|
evas_object_show(btn);
|
2020-10-29 09:43:11 -07:00
|
|
|
elm_table_pack(br, btn, 0, 0, 1, 1);
|
|
|
|
elm_table_pack(br, rec, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
rec = evas_object_rectangle_add(evas_object_evas_get(win));
|
|
|
|
evas_object_size_hint_align_set(rec, FILL, FILL);
|
|
|
|
evas_object_size_hint_weight_set(rec, EXPAND, EXPAND);
|
|
|
|
|
|
|
|
elm_box_pack_end(hbx, version);
|
|
|
|
elm_box_pack_end(hbx, rec);
|
|
|
|
elm_box_pack_end(hbx, br);
|
|
|
|
|
|
|
|
rec = evas_object_rectangle_add(evas_object_evas_get(win));
|
|
|
|
evas_object_size_hint_align_set(rec, FILL, FILL);
|
|
|
|
evas_object_size_hint_min_set(rec, 320 * elm_config_scale_get(), 64);
|
|
|
|
evas_object_color_set(rec, 0, 0, 0, 128);
|
|
|
|
evas_object_show(rec);
|
2020-06-29 07:18:35 -07:00
|
|
|
|
2020-11-14 09:45:22 -08:00
|
|
|
evas_object_smart_callback_add(btn, "clicked", _btn_close_cb, about);
|
2020-06-29 08:05:30 -07:00
|
|
|
|
2020-10-29 09:43:11 -07:00
|
|
|
elm_table_pack(tbl, label, 0, 1, 1, 1);
|
|
|
|
elm_table_pack(tbl, im, 0, 1, 1, 1);
|
|
|
|
elm_table_pack(tbl, rec, 0, 0, 1, 1);
|
|
|
|
elm_table_pack(tbl, hbx, 0, 0, 1, 1);
|
|
|
|
elm_object_content_set(win, tbl);
|
2020-07-03 05:20:24 -07:00
|
|
|
|
2020-06-29 07:18:35 -07:00
|
|
|
evas_object_show(win);
|
|
|
|
}
|
2020-08-30 16:36:00 -07:00
|
|
|
|
|
|
|
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;
|
2020-09-02 14:58:26 -07:00
|
|
|
char *images[] = { "sky_01", "sky_02", "sky_03", "sky_04" };
|
2020-08-30 16:36:00 -07:00
|
|
|
|
|
|
|
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);
|
2020-11-15 14:24:20 -08:00
|
|
|
elm_bg_file_set(bg, evisum_image_path_get("sky_04"), NULL);
|
2020-08-30 16:36:00 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-10-10 06:52:11 -07:00
|
|
|
Eina_Bool
|
|
|
|
evisum_ui_backgrounds_enabled_get(void)
|
|
|
|
{
|
|
|
|
return _backgrounds_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evisum_ui_backgrounds_enabled_set(Eina_Bool enabled)
|
|
|
|
{
|
|
|
|
_backgrounds_enabled = enabled;
|
|
|
|
}
|
|
|
|
|
2020-08-30 16:36:00 -07:00
|
|
|
Eina_Bool
|
|
|
|
evisum_ui_effects_enabled_get(void)
|
|
|
|
{
|
|
|
|
return _effects_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evisum_ui_effects_enabled_set(Eina_Bool enabled)
|
|
|
|
{
|
|
|
|
_effects_enabled = enabled;
|
|
|
|
}
|
2020-09-01 09:03:20 -07:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2020-09-01 14:46:42 -07:00
|
|
|
Ui *ui;
|
2020-09-01 13:34:46 -07:00
|
|
|
int pos;
|
2020-09-01 09:03:20 -07:00
|
|
|
Evas_Object *im;
|
|
|
|
Evas_Object *bolt;
|
|
|
|
} Animation;
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_anim_clouds(void *data)
|
|
|
|
{
|
|
|
|
Ui *ui;
|
|
|
|
Animation *anim;
|
2020-09-01 09:10:08 -07:00
|
|
|
Evas_Coord ww, wh, iw, ih;
|
2020-09-01 09:03:20 -07:00
|
|
|
int cpu;
|
2020-09-09 12:41:09 -07:00
|
|
|
time_t t;
|
2020-09-02 06:23:09 -07:00
|
|
|
static int bolt = 0;
|
2020-09-01 09:03:20 -07:00
|
|
|
|
|
|
|
anim = data;
|
|
|
|
ui = anim->ui;
|
|
|
|
|
|
|
|
evas_object_geometry_get(ui->win, NULL, NULL, &ww, &wh);
|
2020-09-06 05:23:08 -07:00
|
|
|
if (ww <= 0 || wh <= 0) return EINA_TRUE;
|
2020-09-01 09:03:20 -07:00
|
|
|
evas_object_image_size_get(anim->im, &iw, &ih);
|
|
|
|
|
|
|
|
if (ww > iw) iw = ww;
|
|
|
|
|
2020-09-01 13:34:46 -07:00
|
|
|
cpu = (ui->cpu_usage / 10) > 0 ? ui->cpu_usage / 10 : 1;
|
|
|
|
|
2020-09-01 09:03:20 -07:00
|
|
|
evas_object_resize(anim->im, iw, wh);
|
2020-09-11 06:54:02 -07:00
|
|
|
evas_object_image_fill_set(anim->im, anim->pos, -50, iw, ih);
|
2020-09-01 09:03:20 -07:00
|
|
|
anim->pos += cpu;
|
|
|
|
|
2020-09-02 06:23:09 -07:00
|
|
|
t = time(NULL);
|
|
|
|
|
|
|
|
if (cpu >= 6 && !bolt)
|
2020-09-01 09:03:20 -07:00
|
|
|
{
|
2020-09-02 06:23:09 -07:00
|
|
|
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++;
|
2020-09-01 09:03:20 -07:00
|
|
|
}
|
|
|
|
|
2020-09-02 06:23:09 -07:00
|
|
|
if (bolt)
|
2020-09-01 09:03:20 -07:00
|
|
|
{
|
2020-09-09 12:41:09 -07:00
|
|
|
struct timespec ts;
|
2020-09-11 06:14:53 -07:00
|
|
|
|
2020-09-09 12:41:09 -07:00
|
|
|
if (bolt++ == 1)
|
|
|
|
{
|
2020-09-11 06:14:53 -07:00
|
|
|
clock_gettime(CLOCK_REALTIME, &ts);
|
|
|
|
srand(ts.tv_nsec);
|
2020-09-09 12:41:09 -07:00
|
|
|
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);
|
2020-09-01 09:03:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (anim->pos >= iw)
|
2020-09-02 06:23:09 -07:00
|
|
|
anim->pos = 0;
|
2020-09-01 09:03:20 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evisum_ui_animate(void *data)
|
|
|
|
{
|
|
|
|
Animation *anim;
|
|
|
|
Ui *ui;
|
2020-09-11 06:14:53 -07:00
|
|
|
Evas_Object *im;
|
2020-09-01 09:03:20 -07:00
|
|
|
Evas_Coord iw, ih, ww, wh;
|
|
|
|
|
|
|
|
ui = data;
|
|
|
|
|
|
|
|
anim = calloc(1, sizeof(Animation));
|
2020-09-02 06:23:09 -07:00
|
|
|
if (!anim) return;
|
|
|
|
|
2020-09-01 09:03:20 -07:00
|
|
|
anim->ui = ui;
|
|
|
|
|
2020-09-02 06:23:09 -07:00
|
|
|
evas_object_geometry_get(ui->win, NULL, NULL, &ww, &wh);
|
|
|
|
|
2020-09-01 09:03:20 -07:00
|
|
|
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);
|
2020-09-11 06:54:02 -07:00
|
|
|
evas_object_image_fill_set(im, 0, -50, iw, wh);
|
2020-09-01 09:03:20 -07:00
|
|
|
evas_object_resize(im, iw, wh);
|
|
|
|
evas_object_move(im, 0, 0);
|
|
|
|
evas_object_pass_events_set(im, 1);
|
|
|
|
evas_object_show(im);
|
|
|
|
|
2020-11-09 06:28:55 -08:00
|
|
|
ui->processes.animator = ecore_animator_add(_anim_clouds, anim);
|
2020-09-01 09:03:20 -07:00
|
|
|
}
|
|
|
|
|