From 5dc1ebce0eae2ef1bcc1acdc5b2a0c72ccf5fd40 Mon Sep 17 00:00:00 2001 From: Alastair Poole Date: Fri, 22 Jan 2021 09:46:55 +0000 Subject: [PATCH] ui: OS specific checks. OpenBSD does not support listing kernel threads. --- src/bin/ui/ui.c | 31 +++++++++++++++++++++---------- src/bin/ui/ui.h | 2 ++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/bin/ui/ui.c b/src/bin/ui/ui.c index 9bd7d39..eb641bf 100644 --- a/src/bin/ui/ui.c +++ b/src/bin/ui/ui.c @@ -33,7 +33,7 @@ evisum_ui_config_save(Ui *ui) (_evisum_config->proc.show_kthreads != ui->proc.show_kthreads) || (_evisum_config->proc.show_user != ui->proc.show_user) || (_evisum_config->proc.show_scroller != ui->proc.show_scroller) - ) + ) { notify = EINA_TRUE; } @@ -471,15 +471,18 @@ evisum_ui_main_menu_create(Ui *ui, Evas_Object *parent, Evas_Object *obj) evas_object_show(sep); elm_box_pack_end(bx2, sep); - chk = elm_check_add(bx2); - evas_object_size_hint_weight_set(chk, EXPAND, EXPAND); - evas_object_size_hint_align_set(chk, FILL, FILL); - elm_object_text_set(chk, _("Show kernel threads?")); - elm_check_state_set(chk, ui->proc.show_kthreads); - evas_object_show(chk); - evas_object_smart_callback_add(chk, "changed", - _main_menu_show_threads_changed_cb, ui); - elm_box_pack_end(bx2, chk); + if (ui->proc.has_kthreads) + { + chk = elm_check_add(bx2); + evas_object_size_hint_weight_set(chk, EXPAND, EXPAND); + evas_object_size_hint_align_set(chk, FILL, FILL); + elm_object_text_set(chk, _("Show kernel threads?")); + elm_check_state_set(chk, ui->proc.show_kthreads); + evas_object_show(chk); + evas_object_smart_callback_add(chk, "changed", + _main_menu_show_threads_changed_cb, ui); + elm_box_pack_end(bx2, chk); + } chk = elm_check_add(bx2); evas_object_size_hint_weight_set(chk, EXPAND, EXPAND); @@ -515,10 +518,18 @@ evisum_ui_main_menu_create(Ui *ui, Evas_Object *parent, Evas_Object *obj) return o; } +// Any OS specific feature checks. static void _ui_init_system_probe(Ui *ui) { +#if defined(__OpenBSD__) + ui->proc.has_kthreads = 0; +#else + ui->proc.has_kthreads = 1; +#endif +#if defined(__FreeBSD__) || defined(__DragonFly__) ui->mem.zfs_mounted = file_system_in_use("ZFS"); +#endif } void diff --git a/src/bin/ui/ui.h b/src/bin/ui/ui.h index a53695b..2d5585e 100644 --- a/src/bin/ui/ui.h +++ b/src/bin/ui/ui.h @@ -29,6 +29,8 @@ typedef struct Ui int x, y; Eina_Bool restart; + Eina_Bool has_kthreads; + int poll_delay; int sort_type; Eina_Bool sort_reverse;