diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/computer.c | 71 | ||||
-rw-r--r-- | modules/devices/dmi_memory.c | 23 |
2 files changed, 70 insertions, 24 deletions
diff --git a/modules/computer.c b/modules/computer.c index 0123ef26..295a3ed4 100644 --- a/modules/computer.c +++ b/modules/computer.c @@ -76,22 +76,40 @@ void scan_env_var(gboolean reload); void scan_dev(gboolean reload); #endif /* GLIB_CHECK_VERSION(2,14,0) */ +enum { + ENTRY_SUMMARY, + ENTRY_OS, + ENTRY_SECURITY, + ENTRY_KMOD, + ENTRY_BOOTS, + ENTRY_LANGUAGES, + ENTRY_MEMORY_USAGE, + ENTRY_FS, + ENTRY_DISPLAY, + ENTRY_ENV, + ENTRY_DEVEL, + ENTRY_USERS, + ENTRY_GROUPS +}; + static ModuleEntry entries[] = { - {N_("Summary"), "summary.png", callback_summary, scan_summary, MODULE_FLAG_NONE}, - {N_("Operating System"), "os.png", callback_os, scan_os, MODULE_FLAG_NONE}, - {N_("Security"), "security.png", callback_security, scan_security, MODULE_FLAG_NONE}, - {N_("Kernel Modules"), "module.png", callback_modules, scan_modules, MODULE_FLAG_NONE}, - {N_("Boots"), "boot.png", callback_boots, scan_boots, MODULE_FLAG_NONE}, - {N_("Languages"), "language.png", callback_locales, scan_locales, MODULE_FLAG_NONE}, - {N_("Memory Usage"), "memory.png", callback_memory_usage, scan_memory_usage, MODULE_FLAG_NONE}, - {N_("Filesystems"), "dev_removable.png", callback_fs, scan_fs, MODULE_FLAG_NONE}, - {N_("Display"), "monitor.png", callback_display, scan_display, MODULE_FLAG_NONE}, - {N_("Environment Variables"), "environment.png", callback_env_var, scan_env_var, MODULE_FLAG_NONE}, + [ENTRY_SUMMARY] = {N_("Summary"), "summary.png", callback_summary, scan_summary, MODULE_FLAG_NONE}, + [ENTRY_OS] = {N_("Operating System"), "os.png", callback_os, scan_os, MODULE_FLAG_NONE}, + [ENTRY_SECURITY] = {N_("Security"), "security.png", callback_security, scan_security, MODULE_FLAG_NONE}, + [ENTRY_KMOD] = {N_("Kernel Modules"), "module.png", callback_modules, scan_modules, MODULE_FLAG_NONE}, + [ENTRY_BOOTS] = {N_("Boots"), "boot.png", callback_boots, scan_boots, MODULE_FLAG_NONE}, + [ENTRY_LANGUAGES] = {N_("Languages"), "language.png", callback_locales, scan_locales, MODULE_FLAG_NONE}, + [ENTRY_MEMORY_USAGE] = {N_("Memory Usage"), "memory.png", callback_memory_usage, scan_memory_usage, MODULE_FLAG_NONE}, + [ENTRY_FS] = {N_("Filesystems"), "dev_removable.png", callback_fs, scan_fs, MODULE_FLAG_NONE}, + [ENTRY_DISPLAY] = {N_("Display"), "monitor.png", callback_display, scan_display, MODULE_FLAG_NONE}, + [ENTRY_ENV] = {N_("Environment Variables"), "environment.png", callback_env_var, scan_env_var, MODULE_FLAG_NONE}, #if GLIB_CHECK_VERSION(2,14,0) - {N_("Development"), "devel.png", callback_dev, scan_dev, MODULE_FLAG_NONE}, + [ENTRY_DEVEL] = {N_("Development"), "devel.png", callback_dev, scan_dev, MODULE_FLAG_NONE}, +#else + [ENTRY_DEVEL] = {N_("Development"), "devel.png", callback_dev, scan_dev, MODULE_FLAG_HIDE}, #endif /* GLIB_CHECK_VERSION(2,14,0) */ - {N_("Users"), "users.png", callback_users, scan_users, MODULE_FLAG_NONE}, - {N_("Groups"), "users.png", callback_groups, scan_groups, MODULE_FLAG_NONE}, + [ENTRY_USERS] = {N_("Users"), "users.png", callback_users, scan_users, MODULE_FLAG_NONE}, + [ENTRY_GROUPS] = {N_("Groups"), "users.png", callback_groups, scan_groups, MODULE_FLAG_NONE}, {NULL}, }; @@ -1055,3 +1073,30 @@ ModuleAbout *hi_module_get_about(void) return ma; } +static const gchar *hinote_kmod() { + static gchar note[note_max_len] = ""; + gboolean ok = TRUE; + *note = 0; /* clear */ + ok &= note_require_tool("lsmod", note, _("<i><b>lsmod</b></i> is required.")); + return ok ? NULL : g_strstrip(note); /* remove last \n */ +} + +static const gchar *hinote_display() { + static gchar note[note_max_len] = ""; + gboolean ok = TRUE; + *note = 0; /* clear */ + ok &= note_require_tool("xrandr", note, _("X.org's <i><b>xrandr</b></i> utility provides additional details when available.")); + ok &= note_require_tool("glxinfo", note, _("Mesa's <i><b>glxinfo</b></i> utility is required for OpenGL information.")); + return ok ? NULL : g_strstrip(note); /* remove last \n */ +} + +const gchar *hi_note_func(gint entry) +{ + if (entry == ENTRY_KMOD) { + return hinote_kmod(); + } + else if (entry == ENTRY_DISPLAY) { + return hinote_display(); + } + return NULL; +} diff --git a/modules/devices/dmi_memory.c b/modules/devices/dmi_memory.c index 4bb7246e..423b7525 100644 --- a/modules/devices/dmi_memory.c +++ b/modules/devices/dmi_memory.c @@ -977,10 +977,9 @@ gchar *memory_devices_get_system_memory_str() { return ret; } -static gchar *note_state = NULL; +static gchar note_state[note_max_len] = ""; gboolean memory_devices_hinote(const char **msg) { - gchar *want_dmi = _(" <b><i>dmidecode</i></b> utility available"); gchar *want_root = _(" ... <i>and</i> HardInfo running with superuser privileges"); gchar *want_eeprom = _(" <b><i>eeprom</i></b> module loaded (for SDR, DDR, DDR2, DDR3)"); @@ -991,15 +990,17 @@ gboolean memory_devices_hinote(const char **msg) { gboolean has_eeprom = g_file_test("/sys/bus/i2c/drivers/eeprom", G_FILE_TEST_IS_DIR); gboolean has_ee1004 = g_file_test("/sys/bus/i2c/drivers/ee1004", G_FILE_TEST_IS_DIR); - char *bullet_yes = "<big><b>\u2713</b></big>"; - char *bullet_no = "<big><b>\u2022<tt> </tt></b></big>"; - - g_free(note_state); - note_state = g_strdup(_("Memory information requires <b>one or both</b> of the following:")); - note_state = appfnl(note_state, "<tt>1. </tt>%s%s", has_dmi ? bullet_yes : bullet_no, want_dmi); - note_state = appfnl(note_state, "<tt> </tt>%s%s", has_root ? bullet_yes : bullet_no, want_root); - note_state = appfnl(note_state, "<tt>2. </tt>%s%s", has_eeprom ? bullet_yes : bullet_no, want_eeprom); - note_state = appfnl(note_state, "<tt> </tt>%s%s", has_ee1004 ? bullet_yes : bullet_no, want_ee1004); + *note_state = 0; /* clear */ + note_printf(note_state, "%s\n", _("Memory information requires <b>one or both</b> of the following:")); + note_print(note_state, "<tt>1. </tt>"); + note_cond_bullet(has_dmi, note_state, want_dmi); + note_print(note_state, "<tt> </tt>"); + note_cond_bullet(has_root, note_state, want_root); + note_print(note_state, "<tt>2. </tt>"); + note_cond_bullet(has_eeprom, note_state, want_eeprom); + note_print(note_state, "<tt> </tt>"); + note_cond_bullet(has_ee1004, note_state, want_ee1004); + g_strstrip(note_state); /* remove last \n */ gboolean ddr3_ee1004 = ((dmi_ram_types & (1<<DDR3_SDRAM)) && has_ee1004); |