This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository evisum.
View the commit online.
commit 429d2768ace8687ce2d5fbd47800757d806a11e5
Author: Alastair Poole <[email protected]>
AuthorDate: Sat Mar 28 13:55:00 2026 +0000
util: add util functions to their own file space.
---
src/bin/ui/{evisum_ui_util.c => evisum_ui_about.c} | 337 ++-------------------
src/bin/ui/evisum_ui_process_view.c | 3 +-
src/bin/ui/evisum_ui_util.h | 2 +
src/bin/ui/evisum_ui_util_icons.c | 118 ++++++++
src/bin/ui/evisum_ui_util_text.c | 105 +++++++
src/bin/ui/evisum_ui_util_widgets.c | 106 +++++++
src/bin/ui/meson.build | 5 +-
src/bin/ui/util.c | 44 ---
8 files changed, 356 insertions(+), 364 deletions(-)
diff --git a/src/bin/ui/evisum_ui_util.c b/src/bin/ui/evisum_ui_about.c
similarity index 58%
rename from src/bin/ui/evisum_ui_util.c
rename to src/bin/ui/evisum_ui_about.c
index c7ebf51..6d8bdaa 100644
--- a/src/bin/ui/evisum_ui_util.c
+++ b/src/bin/ui/evisum_ui_about.c
@@ -1,11 +1,15 @@
#include "evisum_ui_util.h"
#include "evisum_ui.h"
+
#include <Elementary.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
#include "config.h"
-#define ARRAY_SIZE(n) sizeof(n) / sizeof(n[0])
+#define ARRAY_SIZE(n) (sizeof(n) / sizeof((n)[0]))
#define EVISUM_THEME_FILE PACKAGE_DATA_DIR "/themes/evisum.edj"
-#define EVISUM_THEME_ICON_GROUP_PREFIX "evisum/icons/"
#define EVISUM_ABOUT_BG_WIDTH 560
#define EVISUM_ABOUT_BG_HEIGHT 540
@@ -16,7 +20,7 @@ static const char *about_msg[] = { "The greatest of all time...",
"I endorse this message!",
"Hack the planet!",
"Remember what you need to carry!",
- "Take a break, have a shit chat!",
+ "Take a break, have a shit chat!",
"Well done my son." };
static const char *about_text_fmt = "<font color=#ffffff>"
@@ -47,264 +51,6 @@ _about_random_msg(void) {
return about_msg[rand() % ARRAY_SIZE(about_msg)];
}
-Evas_Object *
-evisum_ui_tab_add(Evas_Object *parent, Evas_Object **alias, const char *text, Evas_Smart_Cb clicked_cb, void *data) {
- Evas_Object *tb, *rect, *btn, *lb;
-
- tb = elm_table_add(parent);
- evas_object_size_hint_weight_set(tb, EXPAND, EXPAND);
- evas_object_size_hint_align_set(tb, FILL, FILL);
-
- rect = evas_object_rectangle_add(evas_object_evas_get(tb));
- 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());
-
- 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);
- evas_object_smart_callback_add(btn, "clicked", clicked_cb, data);
-
- lb = elm_label_add(parent);
- evas_object_size_hint_weight_set(lb, EXPAND, EXPAND);
- evas_object_size_hint_align_set(lb, FILL, FILL);
- evas_object_show(lb);
- elm_object_text_set(lb, eina_slstr_printf("%s", text));
- elm_layout_content_set(btn, "elm.swallow.content", lb);
-
- elm_table_pack(tb, rect, 0, 0, 1, 1);
- elm_table_pack(tb, btn, 0, 0, 1, 1);
-
- if (alias) *alias = btn;
-
- return tb;
-}
-
-Evas_Object *
-evisum_ui_button_add(Evas_Object *parent, Evas_Object **alias, const char *text, const char *icon,
- Evas_Smart_Cb clicked_cb, void *data) {
- Evas_Object *tb, *rect, *btn, *lb, *hbx, *ic;
-
- tb = elm_table_add(parent);
- evas_object_size_hint_weight_set(tb, EXPAND, EXPAND);
- evas_object_size_hint_align_set(tb, FILL, FILL);
-
- rect = evas_object_rectangle_add(evas_object_evas_get(tb));
- evas_object_size_hint_min_set(rect, ELM_SCALE_SIZE(BTN_WIDTH), ELM_SCALE_SIZE(BTN_HEIGHT));
-
- 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);
- evas_object_smart_callback_add(btn, "clicked", clicked_cb, data);
-
- hbx = elm_box_add(parent);
- elm_box_horizontal_set(hbx, 1);
- 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);
- evisum_ui_icon_set(ic, 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);
-
- lb = elm_label_add(parent);
- evas_object_size_hint_weight_set(lb, 1.0, EXPAND);
- evas_object_size_hint_align_set(lb, FILL, FILL);
- evas_object_show(lb);
- elm_object_text_set(lb, eina_slstr_printf("%s", text));
-
- elm_box_pack_end(hbx, lb);
- elm_layout_content_set(btn, "elm.swallow.content", hbx);
-
- elm_table_pack(tb, rect, 0, 0, 1, 1);
- elm_table_pack(tb, btn, 0, 0, 1, 1);
-
- if (alias) *alias = btn;
-
- return tb;
-}
-
-const char *
-evisum_size_format(unsigned long long bytes, Eina_Bool simple) {
- unsigned long powi = 1;
- unsigned long long value;
- unsigned int precision = 2, powj = 1;
- int i = 0;
- static const char *units[8] = {
- _("B"), _("KiB"), _("MiB"), _("GiB"), _("TiB"), _("PiB"), _("EiB"), _("ZiB"),
- };
-
- value = bytes;
- while (value > 1024) {
- if ((value / 1024) < powi) break;
- powi *= 1024;
- ++i;
- if (i == 7) break;
- }
-
- if (!i) precision = 0;
-
- while (precision > 0) {
- powj *= 10;
- if ((value / powi) < powj) break;
- --precision;
- }
-
- if (simple) return eina_slstr_printf("%1.*f %c", precision, (double) value / powi, units[i][0]);
-
- return eina_slstr_printf("%1.*f %s", precision, (double) value / powi, units[i]);
-}
-
-void
-_icon_cache_free_cb(void *data) {
- char *ic_name = data;
-
- free(ic_name);
-}
-
-Eina_Hash *
-evisum_icon_cache_new(void) {
- Eina_Hash *icon_cache;
-
- icon_cache = eina_hash_string_superfast_new(_icon_cache_free_cb);
-
- return icon_cache;
-}
-
-void
-evisum_icon_cache_del(Eina_Hash *icon_cache) {
- eina_hash_free(icon_cache);
-}
-
-const char *
-evisum_icon_cache_find(Eina_Hash *icon_cache, const Proc_Info *proc) {
- Efreet_Desktop *e;
- const char *name, *cmd;
- char *exists;
-
- if (proc->is_kernel)
-#if defined(__linux__)
- return "linux";
-#else
- return "freebsd";
-#endif
-
- cmd = proc->command;
-
- 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) {
- Proc_Info *pproc = proc_info_by_pid(proc->ppid);
-
- if (!pproc) return "application";
- const char *command = evisum_icon_cache_find(icon_cache, pproc);
- proc_info_free(pproc);
- return command;
- }
-
- if (e->icon) name = e->icon;
- else name = cmd;
-
- eina_hash_add(icon_cache, cmd, strdup(name));
-
- efreet_desktop_free(e);
-
- return name;
-}
-
-const char *
-evisum_ui_icon_name_get(const char *name) {
- const char *group;
-
- if (!name) return NULL;
-
- group = eina_slstr_printf(EVISUM_THEME_ICON_GROUP_PREFIX "%s", name);
- if (edje_file_group_exists(EVISUM_THEME_FILE, group)) return group;
-
- return name;
-}
-
-void
-evisum_ui_icon_set(Evas_Object *ic, const char *name) {
- const char *icon;
- Evas_Object *img;
-
- if (!ic || !name) return;
-
- icon = evisum_ui_icon_name_get(name);
- if (!icon) return;
-
- if (!strncmp(icon, EVISUM_THEME_ICON_GROUP_PREFIX, strlen(EVISUM_THEME_ICON_GROUP_PREFIX))) {
- if (elm_image_file_set(ic, EVISUM_THEME_FILE, icon)) {
- elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
- elm_image_smooth_set(ic, EINA_TRUE);
- evas_object_color_set(ic, 255, 255, 255, 255);
- img = elm_image_object_get(ic);
- if (img) {
- const char *type = evas_object_type_get(img);
- evas_object_color_set(img, 255, 255, 255, 255);
- if (type && !strcmp(type, "image")) evas_object_image_alpha_set(img, EINA_TRUE);
- }
- return;
- }
- }
-
- elm_icon_standard_set(ic, icon);
-}
-
-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("font='monospace' DEFAULT='font_size=%d'", new_size));
- evas_object_textblock_style_user_push(tb, ts);
-
- evas_textblock_style_free(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;
-}
-
typedef struct {
Evisum_Ui *ui;
Evas_Object *obj;
@@ -324,11 +70,8 @@ typedef struct {
static void
_win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) {
- Animate_Data *ad;
- Evisum_Ui *ui;
-
- ad = data;
- ui = ad->ui;
+ Animate_Data *ad = data;
+ Evisum_Ui *ui = ad->ui;
if (ad->animator) ecore_animator_del(ad->animator);
if (ad->clip) evas_object_del(ad->clip);
@@ -341,13 +84,11 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
static void
_btn_close_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) {
- Animate_Data *ad;
- Evisum_Ui *ui;
-
- ad = data;
- ui = ad->ui;
+ Animate_Data *ad = data;
+ Evisum_Ui *ui = ad->ui;
evas_object_del(ui->win_about);
+ (void) obj;
}
static void
@@ -358,14 +99,14 @@ _about_resize_cb(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_
evas_object_geometry_get(ad->win, NULL, NULL, &w, &h);
if ((w != ad->w) || (h != ad->h)) evas_object_resize(ad->win, ad->w, ad->h);
evas_object_hide(ad->obj);
+ (void) e;
}
static Eina_Bool
about_anim(void *data) {
- Animate_Data *ad;
+ Animate_Data *ad = data;
double now, dt;
Evas_Coord bx, by, bw, bh, ox, oy, ow, oh;
- ad = data;
evas_object_geometry_get(ad->bg, &bx, &by, &bw, &bh);
evas_object_geometry_get(ad->obj, NULL, NULL, &ow, &oh);
@@ -388,7 +129,6 @@ about_anim(void *data) {
dt = now - ad->last_tick;
ad->last_tick = now;
- /* Clamp long stalls so resume doesn't jump harshly. */
if (dt < 0.0) dt = 0.0;
if (dt > 0.1) dt = 0.1;
@@ -420,20 +160,19 @@ about_anim(void *data) {
static void
_win_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) {
- Evas_Event_Key_Down *ev;
- Animate_Data *ad;
-
- ad = data;
- ev = event_info;
+ Evas_Event_Key_Down *ev = event_info;
+ Animate_Data *ad = data;
if (!ev || !ev->keyname) return;
if (!strcmp(ev->keyname, "Escape")) evas_object_del(ad->ui->win_about);
+ (void) e;
+ (void) obj;
}
void
evisum_about_window_show(void *data) {
- Evisum_Ui *ui;
+ Evisum_Ui *ui = data;
Animate_Data *about;
Evas_Object *win, *bg, *tb, *version, *lb, *btn;
Evas_Object *hbx, *rec, *pad, *pad_left, *pad_right, *clip;
@@ -441,7 +180,6 @@ evisum_about_window_show(void *data) {
Evas_Object *hdr_bg;
int about_w, about_h, bg_w, bg_h, hdr_h, about_pad, btn_h;
- ui = data;
about_w = EVISUM_ABOUT_BG_WIDTH;
about_h = EVISUM_ABOUT_BG_HEIGHT;
about_pad = ELM_SCALE_SIZE(16);
@@ -462,8 +200,6 @@ evisum_about_window_show(void *data) {
elm_win_center(win, 1, 1);
elm_win_title_set(win, _("About"));
- /* All that moves */
-
bg_w = about_w + (about_w / 10);
bg_h = about_h + (about_h / 10);
@@ -530,8 +266,6 @@ evisum_about_window_show(void *data) {
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);
- /* Version overlay */
-
hbx = elm_box_add(win);
elm_box_horizontal_set(hbx, 1);
evas_object_size_hint_align_set(hbx, FILL, FILL);
@@ -597,7 +331,7 @@ evisum_about_window_show(void *data) {
hdr_bg = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_size_hint_align_set(hdr_bg, FILL, 0.0);
evas_object_size_hint_weight_set(hdr_bg, EXPAND, 0);
- evas_object_size_hint_min_set(hdr_bg, about_w, 1); // hdr_h * 2);
+ evas_object_size_hint_min_set(hdr_bg, about_w, 1);
evas_object_color_set(hdr_bg, 0, 0, 0, 77);
evas_object_show(hdr_bg);
@@ -612,34 +346,3 @@ evisum_about_window_show(void *data) {
evas_object_show(win);
}
-
-const char *
-evisum_image_path_get(const char *name) {
- const char *group;
-
- if (!name) return NULL;
-
- group = eina_slstr_printf(EVISUM_THEME_ICON_GROUP_PREFIX "%s", name);
- if (edje_file_group_exists(EVISUM_THEME_FILE, group)) return group;
-
- return NULL;
-}
-
-Evas_Object *
-evisum_ui_background_add(Evas_Object *win) {
- Evas_Object *bg;
-
- bg = elm_bg_add(win);
- evas_object_size_hint_weight_set(bg, EXPAND, EXPAND);
- elm_win_resize_object_add(win, bg);
- evas_object_data_set(win, "bg", bg);
- evas_object_show(bg);
-
- return bg;
-}
-
-void
-evisum_ui_icon_size_set(Evas_Object *ic, int size) {
- evas_object_size_hint_min_set(ic, size, size);
- evas_object_size_hint_max_set(ic, size, size);
-}
diff --git a/src/bin/ui/evisum_ui_process_view.c b/src/bin/ui/evisum_ui_process_view.c
index 14eb6fe..16fab19 100644
--- a/src/bin/ui/evisum_ui_process_view.c
+++ b/src/bin/ui/evisum_ui_process_view.c
@@ -3,7 +3,6 @@
#include "evisum_ui_widget_exel.h"
#include "../system/process.h"
#include "../background/evisum_background.h"
-#include "util.c"
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
@@ -154,7 +153,7 @@ _evisum_ui_process_view_exe_response(const char *command) {
lines = NULL;
while ((fgets(buf, sizeof(buf), p)) != NULL) {
- lines = eina_list_append(lines, _man2entry(buf));
+ lines = eina_list_append(lines, evisum_ui_text_man2entry(buf));
}
pclose(p);
diff --git a/src/bin/ui/evisum_ui_util.h b/src/bin/ui/evisum_ui_util.h
index 8a61278..09dc33e 100644
--- a/src/bin/ui/evisum_ui_util.h
+++ b/src/bin/ui/evisum_ui_util.h
@@ -44,6 +44,8 @@ int evisum_ui_textblock_font_size_get(Evas_Object *tb);
void evisum_ui_textblock_font_size_set(Evas_Object *tb, int new_size);
+char *evisum_ui_text_man2entry(const char *text);
+
void evisum_about_window_show(void *data);
#endif
diff --git a/src/bin/ui/evisum_ui_util_icons.c b/src/bin/ui/evisum_ui_util_icons.c
new file mode 100644
index 0000000..9374f33
--- /dev/null
+++ b/src/bin/ui/evisum_ui_util_icons.c
@@ -0,0 +1,118 @@
+#include "evisum_ui_util.h"
+
+#include <Elementary.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "config.h"
+
+#define EVISUM_THEME_FILE PACKAGE_DATA_DIR "/themes/evisum.edj"
+#define EVISUM_THEME_ICON_GROUP_PREFIX "evisum/icons/"
+
+static void
+_icon_cache_free_cb(void *data) {
+ free(data);
+}
+
+Eina_Hash *
+evisum_icon_cache_new(void) {
+ return eina_hash_string_superfast_new(_icon_cache_free_cb);
+}
+
+void
+evisum_icon_cache_del(Eina_Hash *icon_cache) {
+ eina_hash_free(icon_cache);
+}
+
+const char *
+evisum_icon_cache_find(Eina_Hash *icon_cache, const Proc_Info *proc) {
+ Efreet_Desktop *e;
+ const char *name, *cmd;
+ char *exists;
+
+ if (proc->is_kernel)
+#if defined(__linux__)
+ return "linux";
+#else
+ return "freebsd";
+#endif
+
+ cmd = proc->command;
+
+ 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) {
+ Proc_Info *pproc = proc_info_by_pid(proc->ppid);
+ const char *command;
+
+ if (!pproc) return "application";
+ command = evisum_icon_cache_find(icon_cache, pproc);
+ proc_info_free(pproc);
+ return command;
+ }
+
+ if (e->icon) name = e->icon;
+ else name = cmd;
+
+ eina_hash_add(icon_cache, cmd, strdup(name));
+
+ efreet_desktop_free(e);
+
+ return name;
+}
+
+const char *
+evisum_ui_icon_name_get(const char *name) {
+ const char *group;
+
+ if (!name) return NULL;
+
+ group = eina_slstr_printf(EVISUM_THEME_ICON_GROUP_PREFIX "%s", name);
+ if (edje_file_group_exists(EVISUM_THEME_FILE, group)) return group;
+
+ return name;
+}
+
+const char *
+evisum_image_path_get(const char *name) {
+ const char *group;
+
+ if (!name) return NULL;
+
+ group = eina_slstr_printf(EVISUM_THEME_ICON_GROUP_PREFIX "%s", name);
+ if (edje_file_group_exists(EVISUM_THEME_FILE, group)) return group;
+
+ return NULL;
+}
+
+void
+evisum_ui_icon_set(Evas_Object *ic, const char *name) {
+ const char *icon;
+ Evas_Object *img;
+
+ if (!ic || !name) return;
+
+ icon = evisum_ui_icon_name_get(name);
+ if (!icon) return;
+
+ if (!strncmp(icon, EVISUM_THEME_ICON_GROUP_PREFIX, strlen(EVISUM_THEME_ICON_GROUP_PREFIX))) {
+ if (elm_image_file_set(ic, EVISUM_THEME_FILE, icon)) {
+ elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
+ elm_image_smooth_set(ic, EINA_TRUE);
+ evas_object_color_set(ic, 255, 255, 255, 255);
+ img = elm_image_object_get(ic);
+ if (img) {
+ const char *type = evas_object_type_get(img);
+ evas_object_color_set(img, 255, 255, 255, 255);
+ if (type && !strcmp(type, "image")) evas_object_image_alpha_set(img, EINA_TRUE);
+ }
+ return;
+ }
+ }
+
+ elm_icon_standard_set(ic, icon);
+}
diff --git a/src/bin/ui/evisum_ui_util_text.c b/src/bin/ui/evisum_ui_util_text.c
new file mode 100644
index 0000000..0bdc329
--- /dev/null
+++ b/src/bin/ui/evisum_ui_util_text.c
@@ -0,0 +1,105 @@
+#include "evisum_ui_util.h"
+#include "evisum_ui.h"
+
+#include <Elementary.h>
+#include <stdlib.h>
+#include <string.h>
+
+const char *
+evisum_size_format(unsigned long long bytes, Eina_Bool simple) {
+ unsigned long powi = 1;
+ unsigned long long value;
+ unsigned int precision = 2, powj = 1;
+ int i = 0;
+ static const char *units[8] = {
+ _("B"), _("KiB"), _("MiB"), _("GiB"), _("TiB"), _("PiB"), _("EiB"), _("ZiB"),
+ };
+
+ value = bytes;
+ while (value > 1024) {
+ if ((value / 1024) < powi) break;
+ powi *= 1024;
+ ++i;
+ if (i == 7) break;
+ }
+
+ if (!i) precision = 0;
+
+ while (precision > 0) {
+ powj *= 10;
+ if ((value / powi) < powj) break;
+ --precision;
+ }
+
+ if (simple) return eina_slstr_printf("%1.*f %c", precision, (double) value / powi, units[i][0]);
+
+ return eina_slstr_printf("%1.*f %s", precision, (double) value / powi, units[i]);
+}
+
+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("font='monospace' DEFAULT='font_size=%d'", new_size));
+ evas_object_textblock_style_user_push(tb, ts);
+ evas_textblock_style_free(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);
+ if (!p) return size;
+
+ p1 = strstr(p, "font_size=");
+ if (p1) {
+ p1 += 10;
+ size = atoi(p1);
+ }
+
+ free(p);
+
+ return size;
+}
+
+char *
+evisum_ui_text_man2entry(const char *text) {
+ Eina_Strbuf *sb;
+ const char *p;
+ char *out;
+
+ if (!text) return NULL;
+
+ sb = eina_strbuf_new();
+ if (!sb) return NULL;
+
+ for (p = text; *p; p++) {
+ switch (*p) {
+ case '<': eina_strbuf_append(sb, "<"); break;
+ case '>': eina_strbuf_append(sb, ">"); break;
+ case '&': eina_strbuf_append(sb, "&"); break;
+ case '\t': eina_strbuf_append(sb, " "); break;
+ default: eina_strbuf_append_char(sb, *p); break;
+ }
+ }
+
+ out = eina_strbuf_string_steal(sb);
+ eina_strbuf_free(sb);
+
+ return out;
+}
diff --git a/src/bin/ui/evisum_ui_util_widgets.c b/src/bin/ui/evisum_ui_util_widgets.c
new file mode 100644
index 0000000..622ccd7
--- /dev/null
+++ b/src/bin/ui/evisum_ui_util_widgets.c
@@ -0,0 +1,106 @@
+#include "evisum_ui_util.h"
+
+#include <Elementary.h>
+
+Evas_Object *
+evisum_ui_tab_add(Evas_Object *parent, Evas_Object **alias, const char *text, Evas_Smart_Cb clicked_cb, void *data) {
+ Evas_Object *tb, *rect, *btn, *lb;
+
+ tb = elm_table_add(parent);
+ evas_object_size_hint_weight_set(tb, EXPAND, EXPAND);
+ evas_object_size_hint_align_set(tb, FILL, FILL);
+
+ rect = evas_object_rectangle_add(evas_object_evas_get(tb));
+ 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());
+
+ 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);
+ evas_object_smart_callback_add(btn, "clicked", clicked_cb, data);
+
+ lb = elm_label_add(parent);
+ evas_object_size_hint_weight_set(lb, EXPAND, EXPAND);
+ evas_object_size_hint_align_set(lb, FILL, FILL);
+ evas_object_show(lb);
+ elm_object_text_set(lb, eina_slstr_printf("%s", text));
+ elm_layout_content_set(btn, "elm.swallow.content", lb);
+
+ elm_table_pack(tb, rect, 0, 0, 1, 1);
+ elm_table_pack(tb, btn, 0, 0, 1, 1);
+
+ if (alias) *alias = btn;
+
+ return tb;
+}
+
+Evas_Object *
+evisum_ui_button_add(Evas_Object *parent, Evas_Object **alias, const char *text, const char *icon,
+ Evas_Smart_Cb clicked_cb, void *data) {
+ Evas_Object *tb, *rect, *btn, *lb, *hbx, *ic;
+
+ tb = elm_table_add(parent);
+ evas_object_size_hint_weight_set(tb, EXPAND, EXPAND);
+ evas_object_size_hint_align_set(tb, FILL, FILL);
+
+ rect = evas_object_rectangle_add(evas_object_evas_get(tb));
+ evas_object_size_hint_min_set(rect, ELM_SCALE_SIZE(BTN_WIDTH), ELM_SCALE_SIZE(BTN_HEIGHT));
+
+ 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);
+ evas_object_smart_callback_add(btn, "clicked", clicked_cb, data);
+
+ hbx = elm_box_add(parent);
+ elm_box_horizontal_set(hbx, 1);
+ 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);
+ evisum_ui_icon_set(ic, 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);
+
+ lb = elm_label_add(parent);
+ evas_object_size_hint_weight_set(lb, 1.0, EXPAND);
+ evas_object_size_hint_align_set(lb, FILL, FILL);
+ evas_object_show(lb);
+ elm_object_text_set(lb, eina_slstr_printf("%s", text));
+
+ elm_box_pack_end(hbx, lb);
+ elm_layout_content_set(btn, "elm.swallow.content", hbx);
+
+ elm_table_pack(tb, rect, 0, 0, 1, 1);
+ elm_table_pack(tb, btn, 0, 0, 1, 1);
+
+ if (alias) *alias = btn;
+
+ return tb;
+}
+
+Evas_Object *
+evisum_ui_background_add(Evas_Object *win) {
+ Evas_Object *bg;
+
+ bg = elm_bg_add(win);
+ evas_object_size_hint_weight_set(bg, EXPAND, EXPAND);
+ elm_win_resize_object_add(win, bg);
+ evas_object_data_set(win, "bg", bg);
+ evas_object_show(bg);
+
+ return bg;
+}
+
+void
+evisum_ui_icon_size_set(Evas_Object *ic, int size) {
+ evas_object_size_hint_min_set(ic, size, size);
+ evas_object_size_hint_max_set(ic, size, size);
+}
diff --git a/src/bin/ui/meson.build b/src/bin/ui/meson.build
index 048ed07..296ac25 100644
--- a/src/bin/ui/meson.build
+++ b/src/bin/ui/meson.build
@@ -5,7 +5,10 @@ src += files([
'evisum_ui_colors.c',
'evisum_ui_colors.h',
'evisum_ui_util.h',
- 'evisum_ui_util.c',
+ 'evisum_ui_about.c',
+ 'evisum_ui_util_icons.c',
+ 'evisum_ui_util_text.c',
+ 'evisum_ui_util_widgets.c',
'evisum_ui_graph.h',
'evisum_ui_graph.c',
'evisum_ui_cache.c',
diff --git a/src/bin/ui/util.c b/src/bin/ui/util.c
deleted file mode 100644
index e567ca1..0000000
--- a/src/bin/ui/util.c
+++ /dev/null
@@ -1,44 +0,0 @@
-
-// Process Window includes this junk.
-
-static char *
-_man2entry(const char *text) {
- const char *p;
- char *str;
- void *tmp;
- int i = 0, len = strlen(text) + 1;
-
- str = malloc(len);
- if (!str) return NULL;
- p = text;
-
- while (*p) {
- if (*p == '<') {
- tmp = realloc(str, (len += 4));
- str = tmp;
- memcpy(&str[i], "<", 4);
- i += 4;
- } else if (*p == '>') {
- tmp = realloc(str, (len += 4));
- str = tmp;
- memcpy(&str[i], ">", 4);
- i += 4;
- } else if (*p == '&') {
- tmp = realloc(str, (len += 5));
- str = tmp;
- memcpy(&str[i], "&", 5);
- i += 5;
- } else if (*p == '\t') {
- tmp = realloc(str, (len += 8));
- str = tmp;
- memcpy(&str[i], " ", 8);
- i += 8;
- } else {
- str[i++] = *p;
- }
- p++;
- }
- str[i] = '\0';
-
- return str;
-}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.