Skip to content
Permalink
Browse files

various: entry hide flag, fix text format report, fix key_*() funcs

* fix key_is_highlighted() and key_wants_details() so that they
  don't look for flags in the label.
* fix -r -f text, g_hash-related warnings from icon cache
* add MODULE_FLAG_HIDE flag to hide module entries instead of
  using the '#' at the beginning of string hack, which didn't
  work everywhere, and screwed up translated strings.
* hide GPU Drawing benchmark
  See: #329

Signed-off-by: Burt P <pburt0@gmail.com>
  • Loading branch information...
bp0 authored and lpereira committed Aug 18, 2019
1 parent f6b11e2 commit 9d825229c63d8618802749e294126ff6e118042a
Showing with 23 additions and 15 deletions.
  1. +1 −0 includes/hardinfo.h
  2. +4 −4 modules/benchmark/benches.c
  3. +1 −1 modules/devices.c
  4. +2 −0 shell/report.c
  5. +15 −10 shell/shell.c
@@ -40,6 +40,7 @@ typedef enum {
MODULE_FLAG_NONE = 0,
MODULE_FLAG_NO_REMOTE = 1<<0,
MODULE_FLAG_HAS_HELP = 1<<1,
MODULE_FLAG_HIDE = 1<<2,
} ModuleEntryFlags;

typedef struct _ModuleEntry ModuleEntry;
@@ -101,16 +101,16 @@ static ModuleEntry entries[] = {
[BENCHMARK_SBCPU_ALL] =
{N_("SysBench CPU (Multi-thread)"), "processor.png", callback_benchmark_sbcpu_all, scan_benchmark_sbcpu_all, MODULE_FLAG_NONE},
[BENCHMARK_SBCPU_QUAD] =
{N_("#SysBench CPU (Four threads)"), "processor.png", callback_benchmark_sbcpu_quad, scan_benchmark_sbcpu_quad, MODULE_FLAG_NONE},
{N_("#SysBench CPU (Four threads)"), "processor.png", callback_benchmark_sbcpu_quad, scan_benchmark_sbcpu_quad, MODULE_FLAG_HIDE},
[BENCHMARK_MEMORY_SINGLE] =
{N_("#SysBench Memory (Single-thread)"), "memory.png", callback_benchmark_memory_single, scan_benchmark_memory_single, MODULE_FLAG_NONE},
{N_("#SysBench Memory (Single-thread)"), "memory.png", callback_benchmark_memory_single, scan_benchmark_memory_single, MODULE_FLAG_HIDE},
[BENCHMARK_MEMORY_DUAL] =
{N_("#SysBench Memory (Two threads)"), "memory.png", callback_benchmark_memory_dual, scan_benchmark_memory_dual, MODULE_FLAG_NONE},
{N_("#SysBench Memory (Two threads)"), "memory.png", callback_benchmark_memory_dual, scan_benchmark_memory_dual, MODULE_FLAG_HIDE},
[BENCHMARK_MEMORY_QUAD] =
{N_("SysBench Memory"), "memory.png", callback_benchmark_memory_quad, scan_benchmark_memory_quad, MODULE_FLAG_NONE},
#if !GTK_CHECK_VERSION(3,0,0)
[BENCHMARK_GUI] =
{N_("GPU Drawing"), "module.png", callback_gui, scan_gui, MODULE_FLAG_NO_REMOTE},
{N_("GPU Drawing"), "module.png", callback_gui, scan_gui, MODULE_FLAG_NO_REMOTE | MODULE_FLAG_HIDE},
#else
[BENCHMARK_GUI] = { "#" },
#endif
@@ -110,7 +110,7 @@ static ModuleEntry entries[] = {
[ENTRY_DMI] = {N_("System DMI"), "computer.png", callback_dmi, scan_dmi, MODULE_FLAG_NONE},
[ENTRY_DMI_MEM] = {N_("Memory Devices"), "memory.png", callback_dmi_mem, scan_dmi_mem, MODULE_FLAG_NONE},
#if defined(ARCH_x86) || defined(ARCH_x86_64)
[ENTRY_DTREE] = {"#"},
[ENTRY_DTREE] = {N_("Device Tree"), "devices.png", callback_dtree, scan_dtree, MODULE_FLAG_HIDE},
#else
[ENTRY_DTREE] = {N_("Device Tree"), "devices.png", callback_dtree, scan_dtree, MODULE_FLAG_NONE},
#endif /* x86 or x86_64 */
@@ -126,6 +126,7 @@ gchar *make_icon_css(const gchar *file) {
}

void cache_icon(ReportContext *ctx, const gchar *file) {
if (!ctx->icon_data) return;
if (!g_hash_table_lookup(ctx->icon_data, file) )
g_hash_table_insert(ctx->icon_data, g_strdup(file), make_icon_css(file));
}
@@ -684,6 +685,7 @@ report_create_inner_from_module_list(ReportContext * ctx, GSList * modules)

for (entries = module->entries; entries; entries = entries->next) {
ShellModuleEntry *entry = (ShellModuleEntry *) entries->data;
if (entry->flags & MODULE_FLAG_HIDE) continue;

if (!params.gui_running)
fprintf(stderr, "\033[2K\033[40;32;1m %s\033[0m\n",
@@ -648,6 +648,7 @@ void shell_add_modules_to_gui(gpointer _shell_module, gpointer _shell_tree)
for (p = module->entries; p; p = g_slist_next(p)) {
GtkTreeIter child;
entry = (ShellModuleEntry *) p->data;
if (entry->flags & MODULE_FLAG_HIDE) continue;

gtk_tree_store_append(store, &child, &parent);
gtk_tree_store_set(store, &child, TREE_COL_NAME, entry->name,
@@ -2165,17 +2166,21 @@ gboolean key_is_flagged(const gchar *key) {
}

gboolean key_is_highlighted(const gchar *key) {
if (key_is_flagged(key)) {
if (strchr(key, '*'))
return TRUE;
gchar *flags;
key_get_components(key, &flags, NULL, NULL, NULL, NULL, TRUE);
if (flags && strchr(flags, '*')) {
g_free(flags);
return TRUE;
}
return FALSE;
}

gboolean key_wants_details(const gchar *key) {
if (key_is_flagged(key)) {
if (strchr(key, '!'))
return TRUE;
gchar *flags;
key_get_components(key, &flags, NULL, NULL, NULL, NULL, TRUE);
if (flags && strchr(flags, '!')) {
g_free(flags);
return TRUE;
}
return FALSE;
}
@@ -2217,18 +2222,18 @@ void key_get_components(const gchar *key,
gchar **flags, gchar **tag, gchar **name, gchar **label, gchar **dis,
gboolean null_empty) {

if (!key || !*key)
return;

if (null_empty) {
#define K_NULL_EMPTY(f) if (f && *f) { *f = NULL; }
#define K_NULL_EMPTY(f) if (f) { *f = NULL; }
K_NULL_EMPTY(flags);
K_NULL_EMPTY(tag);
K_NULL_EMPTY(name);
K_NULL_EMPTY(label);
K_NULL_EMPTY(dis);
}

if (!key || !*key)
return;

const gchar *np = g_utf8_strchr(key+1, -1, '$') + 1;
if (*key == '$' && np) {
/* is flagged */

0 comments on commit 9d82522

Please sign in to comment.
You can’t perform that action at this time.