diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-03-21 10:54:54 +0000 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-03-21 10:54:54 +0000 |
commit | 71a591195618271973a12ae7ffaf288909481cbc (patch) | |
tree | 68ea841f948f1351099dd470ba966edf42125047 /hardinfo2 | |
parent | f7ab0cb977df0d6eba533a245c93da582b9f5f84 (diff) |
Cleanups. APM battery info fixes for Linux 2.6.
Diffstat (limited to 'hardinfo2')
-rw-r--r-- | hardinfo2/Makefile.in | 1 | ||||
-rw-r--r-- | hardinfo2/arch/linux/common/battery.h | 63 | ||||
-rw-r--r-- | hardinfo2/arch/linux/common/os.h | 4 | ||||
-rw-r--r-- | hardinfo2/arch/linux/x86/processor.h | 102 | ||||
-rw-r--r-- | hardinfo2/callbacks.c | 5 | ||||
-rw-r--r-- | hardinfo2/callbacks.h | 1 | ||||
-rwxr-xr-x | hardinfo2/configure | 4 | ||||
-rw-r--r-- | hardinfo2/hardinfo.c | 3 | ||||
-rw-r--r-- | hardinfo2/menu.c | 5 | ||||
-rw-r--r-- | hardinfo2/pixmaps/face-grin.png | bin | 0 -> 905 bytes | |||
-rw-r--r-- | hardinfo2/stock.c | 1 | ||||
-rw-r--r-- | hardinfo2/stock.h | 1 | ||||
-rw-r--r-- | hardinfo2/syncmanager.c | 4 | ||||
-rw-r--r-- | hardinfo2/uidefs.h | 2 | ||||
-rw-r--r-- | hardinfo2/uidefs.xml | 42 | ||||
-rw-r--r-- | hardinfo2/util.c | 4 |
16 files changed, 119 insertions, 123 deletions
diff --git a/hardinfo2/Makefile.in b/hardinfo2/Makefile.in index 40b4f29f..6acd957a 100644 --- a/hardinfo2/Makefile.in +++ b/hardinfo2/Makefile.in @@ -77,7 +77,6 @@ install: all cp -Lr pixmaps/* ${DESTDIR}/usr/share/hardinfo/pixmaps @echo '[01;34m*** Installing misc data...[00m' - cp uidefs.xml ${DESTDIR}/usr/share/hardinfo cp benchmark.conf ${DESTDIR}/usr/share/hardinfo cp benchmark.data ${DESTDIR}/usr/share/hardinfo diff --git a/hardinfo2/arch/linux/common/battery.h b/hardinfo2/arch/linux/common/battery.h index 919dc65d..20979e48 100644 --- a/hardinfo2/arch/linux/common/battery.h +++ b/hardinfo2/arch/linux/common/battery.h @@ -136,27 +136,31 @@ __scan_battery_apm(void) static char *sremaining = NULL, *stotal = NULL; static unsigned int last_time = 0; static int percentage = 0; + const char *ac_status[] = { "Battery", + "AC Power", + "Charging" }; int ac_bat; - float apm_bios_ver, apm_drv_ver; + char apm_bios_ver[16], apm_drv_ver[16]; char trash[10]; - if (last_time == 0) { - last_time = time(NULL); - sremaining = g_strdup("Estimating"); - stotal = g_strdup("Estimating"); - } - if ((procapm = fopen("/proc/apm", "r"))) { int old_percentage = percentage; - fscanf(procapm, "%f %f %s 0x%x %s %s %d%%", - &apm_drv_ver, &apm_bios_ver, trash, + fscanf(procapm, "%s %s %s 0x%x %s %s %d%%", + apm_drv_ver, apm_bios_ver, trash, &ac_bat, trash, trash, &percentage); fclose(procapm); + if (last_time == 0) { + last_time = time(NULL); + sremaining = stotal = NULL; + } + if (old_percentage - percentage > 0) { - g_free(sremaining); - g_free(stotal); + if (sremaining && stotal) { + g_free(sremaining); + g_free(stotal); + } int secs_remaining = (time(NULL) - last_time) * percentage / (old_percentage - percentage); @@ -165,19 +169,34 @@ __scan_battery_apm(void) last_time = time(NULL); } + } else { + return; } - battery_list = g_strdup_printf("%s\n[Battery (APM)]\n" - "Charge=%d%%\n" - "Remaining Charge=%s of %s\n" - "Using=%s\n" - "APM driver version=%.2f\n" - "APM BIOS version=%.2f\n", - battery_list, - percentage, - sremaining, stotal, - ac_bat ? "AC Power" : "Battery", - apm_drv_ver, apm_bios_ver); + if (stotal && sremaining) { + battery_list = g_strdup_printf("%s\n[Battery (APM)]\n" + "Charge=%d%%\n" + "Remaining Charge=%s of %s\n" + "Using=%s\n" + "APM driver version=%s\n" + "APM BIOS version=%s\n", + battery_list, + percentage, + sremaining, stotal, + ac_status[ac_bat], + apm_drv_ver, apm_bios_ver); + } else { + battery_list = g_strdup_printf("%s\n[Battery (APM)]\n" + "Charge=%d%%\n" + "Using=%s\n" + "APM driver version=%s\n" + "APM BIOS version=%s\n", + battery_list, + percentage, + ac_status[ac_bat], + apm_drv_ver, apm_bios_ver); + + } } static void diff --git a/hardinfo2/arch/linux/common/os.h b/hardinfo2/arch/linux/common/os.h index b4404925..d30146ef 100644 --- a/hardinfo2/arch/linux/common/os.h +++ b/hardinfo2/arch/linux/common/os.h @@ -75,7 +75,9 @@ detect_desktop_environment(OperatingSystem * os) obtain the version. */ version = popen("gnome-panel --version", "r"); if (version) { - fscanf(version, "Gnome gnome-panel %d.%d", &maj, &min); + char gnome[10]; + + fscanf(version, "%s gnome-panel %d.%d", gnome, &maj, &min); if (pclose(version)) goto unknown; } else { diff --git a/hardinfo2/arch/linux/x86/processor.h b/hardinfo2/arch/linux/x86/processor.h index e9985d2c..918bac7c 100644 --- a/hardinfo2/arch/linux/x86/processor.h +++ b/hardinfo2/arch/linux/x86/processor.h @@ -86,7 +86,7 @@ static void get_processor_strfamily(Processor * processor) } } else if (family == 6) { if (model == 1) { - processor->strmodel = g_strdup("AMD Athlon (K7"); + processor->strmodel = g_strdup("AMD Athlon (K7)"); } else if (model == 2) { processor->strmodel = g_strdup("AMD Athlon (K75)"); } else if (model == 3) { @@ -211,51 +211,50 @@ static GSList *__scan_processors(void) static struct { char *name, *meaning; } flag_meaning[] = { - { - "3dnow", "3DNow! Technology"}, { - "3dnowext", "Extended 3DNow! Technology"}, { - "fpu", "Floating Point Unit"}, { - "vme", "Virtual 86 Mode Extension"}, { - "de", "Debug Extensions - I/O breakpoints"}, { - "pse", "Page Size Extensions (4MB pages)"}, { - "tsc", "Time Stamp Counter and RDTSC instruction"}, { - "msr", "Model Specific Registers"}, { - "pae", "Physical Address Extensions (36-bit address, 2MB pages)"}, { - "mce", "Machine Check Architeture"}, { - "cx8", "CMPXCHG8 instruction"}, { - "apic", "Advanced Programmable Interrupt Controller"}, { - "sep", "Fast System Call (SYSENTER/SYSEXIT instructions)"}, { - "mtrr", "Memory Type Range Registers"}, { - "pge", "Page Global Enable"}, { - "mca", "Machine Check Architecture"}, { - "cmov", "Conditional Move instruction"}, { - "pat", "Page Attribute Table"}, { - "pse36", "36bit Page Size Extensions"}, { - "psn", "96 bit Processor Serial Number"}, { - "mmx", "MMX technology"}, { - "mmxext", "Extended MMX Technology"}, { - "cflush", "Cache Flush"}, { - "dtes", "Debug Trace Store"}, { - "fxsr", "FXSAVE and FXRSTOR instructions"}, { - "kni", "Streaming SIMD instructions"}, { - "xmm", "Streaming SIMD instructions"}, { - "ht", "HyperThreading"}, { - "mp", "Multiprocessing Capable"}, { - "sse", "SSE instructions"}, { - "sse2", "SSE2 (WNI) instructions"}, { - "acc", "Automatic Clock Control"}, { - "ia64", "IA64 Instructions"}, { - "syscall", "SYSCALL and SYSEXIT instructions"}, { - "nx", "No-execute Page Protection"}, { - "xd", "Execute Disable"}, { - "clflush", "Cache Line Flush instruction"}, { - "acpi", "Thermal Monitor and Software Controlled Clock Facilities"}, { - "dts", "Debug Store"}, { - "ss", "Self Snoop"}, { - "tm", "Thermal Monitor"}, { - "pbe", "Pending Break Enable"}, { - "pb", "Pending Break Enable"}, { - NULL, NULL} + { "3dnow", "3DNow! Technology" }, + { "3dnowext", "Extended 3DNow! Technology" }, + { "fpu", "Floating Point Unit" }, + { "vme", "Virtual 86 Mode Extension" }, + { "de", "Debug Extensions - I/O breakpoints" }, + { "pse", "Page Size Extensions (4MB pages)" }, + { "tsc", "Time Stamp Counter and RDTSC instruction" }, + { "msr", "Model Specific Registers" }, + { "pae", "Physical Address Extensions" }, + { "mce", "Machine Check Architeture" }, + { "cx8", "CMPXCHG8 instruction" }, + { "apic", "Advanced Programmable Interrupt Controller" }, + { "sep", "Fast System Call (SYSENTER/SYSEXIT)" }, + { "mtrr", "Memory Type Range Registers" }, + { "pge", "Page Global Enable" }, + { "mca", "Machine Check Architecture" }, + { "cmov", "Conditional Move instruction" }, + { "pat", "Page Attribute Table" }, + { "pse36", "36bit Page Size Extensions" }, + { "psn", "96 bit Processor Serial Number" }, + { "mmx", "MMX technology" }, + { "mmxext", "Extended MMX Technology" }, + { "cflush", "Cache Flush" }, + { "dtes", "Debug Trace Store" }, + { "fxsr", "FXSAVE and FXRSTOR instructions" }, + { "kni", "Streaming SIMD instructions" }, + { "xmm", "Streaming SIMD instructions" }, + { "ht", "HyperThreading" }, + { "mp", "Multiprocessing Capable" }, + { "sse", "SSE instructions" }, + { "sse2", "SSE2 (WNI) instructions" }, + { "acc", "Automatic Clock Control" }, + { "ia64", "IA64 Instructions" }, + { "syscall", "SYSCALL and SYSEXIT instructions" }, + { "nx", "No-execute Page Protection" }, + { "xd", "Execute Disable" }, + { "clflush", "Cache Line Flush instruction" }, + { "acpi", "Thermal Monitor and Software Controlled Clock" }, + { "dts", "Debug Store" }, + { "ss", "Self Snoop" }, + { "tm", "Thermal Monitor" }, + { "pbe", "Pending Break Enable" }, + { "pb", "Pending Break Enable" }, + { NULL, NULL }, }; gchar *processor_get_capabilities_from_flags(gchar * strflags) @@ -295,12 +294,12 @@ static gchar *processor_get_detailed_info(Processor * processor) tmp = processor_get_capabilities_from_flags(processor->flags); ret = g_strdup_printf("[Processor]\n" "Name=%s\n" - "Specification=%s\n" - "Family, model, stepping=%d, %d, %d\n" + "Family, model, stepping=%d, %d, %d (%s)\n" "Vendor=%s\n" + "[Configuration]\n" "Cache Size=%dkb\n" "Frequency=%.2fMHz\n" - "BogoMips=%.2f\n" + "BogoMIPS=%.2f\n" "Byte Order=%s\n" "[Features]\n" "FDIV Bug=%s\n" @@ -308,12 +307,13 @@ static gchar *processor_get_detailed_info(Processor * processor) "F00F Bug=%s\n" "Coma Bug=%s\n" "Has FPU=%s\n" - "[Capabilities]\n" "%s", - processor->strmodel, + "[Capabilities]\n" + "%s", processor->model_name, processor->family, processor->model, processor->stepping, + processor->strmodel, vendor_get_name(processor->vendor_id), processor->cache_size, processor->cpu_mhz, processor->bogomips, diff --git a/hardinfo2/callbacks.c b/hardinfo2/callbacks.c index 31fa9441..ac47d089 100644 --- a/hardinfo2/callbacks.c +++ b/hardinfo2/callbacks.c @@ -84,6 +84,11 @@ void cb_report_bug() open_url("http://hardinfo.berlios.de/web/BugReports"); } +void cb_donate() +{ + open_url("http://hardinfo.berlios.de/web/Donate"); +} + void cb_refresh() { shell_do_reload(); diff --git a/hardinfo2/callbacks.h b/hardinfo2/callbacks.h index f730381d..0387df05 100644 --- a/hardinfo2/callbacks.h +++ b/hardinfo2/callbacks.h @@ -34,5 +34,6 @@ void cb_open_web_page(); void cb_open_online_docs(); void cb_sync_manager(); void cb_report_bug(); +void cb_donate(); #endif /* __CALLBACKS_H__ */ diff --git a/hardinfo2/configure b/hardinfo2/configure index 26ab11b3..1b43e8ca 100755 --- a/hardinfo2/configure +++ b/hardinfo2/configure @@ -24,7 +24,7 @@ PACKAGE=`basename ${PWD} | cut -d"-" -f1`; VERSION=`basename ${PWD} | cut -d"-" -f2`; if [ "$PACKAGE" == "$VERSION" ]; then - VERSION=$(printf "SVN_%d" $(svn -R info|grep Revision|cut -d: -f2|sort -n|tail -n1)) + VERSION=$(printf "SVN_%d" $(LC_ALL=C svn -R info|grep Revision|cut -d: -f2|sort -n|tail -n1)) RELEASE=0 else RELEASE=1 @@ -194,7 +194,7 @@ echo "#define PREFIX \"/usr/share/hardinfo/\"" >> config.h echo "#define LIBPREFIX \"/usr/lib/hardinfo/\"" >> config.h if [ "$RELEASE" == "1" ]; then - echo "#define DEBUG(...) (void)" >> config.h + echo "#define DEBUG(...)" >> config.h else echo '#define DEBUG(msg,...) fprintf(stderr, "*** %s:%d (%s) *** " msg "\n", \' >> config.h echo ' __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)' >> config.h diff --git a/hardinfo2/hardinfo.c b/hardinfo2/hardinfo.c index 8d17ffc1..ea075f5d 100644 --- a/hardinfo2/hardinfo.c +++ b/hardinfo2/hardinfo.c @@ -66,7 +66,6 @@ main(int argc, char **argv) } /* initialize the binreloc library, so we can load program data */ - DEBUG("initializing binreloc"); if (!binreloc_init(FALSE)) g_error("Failed to find runtime data.\n\n" "\342\200\242 Is HardInfo correctly installed?\n" @@ -95,7 +94,6 @@ main(int argc, char **argv) if (!params.create_report) { /* we only try to open the UI if the user didn't asked for a report. */ - DEBUG("initializing gtk+"); params.gui_running = ui_init(&argc, &argv); /* as a fallback, if GTK+ initialization failed, run in report @@ -121,7 +119,6 @@ main(int argc, char **argv) shell_init(modules); - DEBUG("entering gtk+ main loop"); gtk_main(); } else if (params.create_report) { diff --git a/hardinfo2/menu.c b/hardinfo2/menu.c index 3b45cef0..4d6373e5 100644 --- a/hardinfo2/menu.c +++ b/hardinfo2/menu.c @@ -78,6 +78,11 @@ static GtkActionEntry entries[] = NULL, G_CALLBACK(cb_report_bug) }, + { "DonateAction", HI_STOCK_DONATE, + "_Donate to the project", NULL, + NULL, + G_CALLBACK(cb_donate) }, + { "AboutAction", GTK_STOCK_ABOUT, "_About HardInfo", NULL, "Displays program version information", diff --git a/hardinfo2/pixmaps/face-grin.png b/hardinfo2/pixmaps/face-grin.png Binary files differnew file mode 100644 index 00000000..d15cf2d4 --- /dev/null +++ b/hardinfo2/pixmaps/face-grin.png diff --git a/hardinfo2/stock.c b/hardinfo2/stock.c index 6387273a..438dfa38 100644 --- a/hardinfo2/stock.c +++ b/hardinfo2/stock.c @@ -30,6 +30,7 @@ static struct { { "module.png", HI_STOCK_MODULE }, { "about-modules.png", HI_STOCK_ABOUT_MODULES }, { "syncmanager-small.png", HI_STOCK_SYNC_MENU }, + { "face-grin.png", HI_STOCK_DONATE }, }; static GtkIconFactory *icon_factory; diff --git a/hardinfo2/stock.h b/hardinfo2/stock.h index 236fdfb4..7f6b2742 100644 --- a/hardinfo2/stock.h +++ b/hardinfo2/stock.h @@ -24,6 +24,7 @@ #define HI_STOCK_MODULE "hi-stock-module" #define HI_STOCK_ABOUT_MODULES "hi-stock-about-modules" #define HI_STOCK_SYNC_MENU "hi-stock-sync-menu" +#define HI_STOCK_DONATE "hi-stock-donate" void stock_icons_init(void); void stock_icon_register(gchar *filename, gchar *stock_id); diff --git a/hardinfo2/syncmanager.c b/hardinfo2/syncmanager.c index cf091b3a..c99b134f 100644 --- a/hardinfo2/syncmanager.c +++ b/hardinfo2/syncmanager.c @@ -66,7 +66,7 @@ static GQuark err_quark; #define XMLRPC_SERVER_URI "http://hardinfo.berlios.de/xmlrpc/" #define XMLRPC_SERVER_API_VERSION 1 -#define LABEL_SYNC_DEFAULT "<big><b>Synchronize with Central Database</b></big>\n" \ +#define LABEL_SYNC_DEFAULT "<big><b>Synchronize with Central Database</b></big>\n" \ "The following information may be synchronized " \ "with the HardInfo central database." #define LABEL_SYNC_SYNCING "<big><b>Synchronizing</b></big>\n" \ @@ -553,6 +553,8 @@ static void populate_store(GtkListStore *store) e = (SyncEntry *) entry->data; + e->selected = TRUE; + gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, TRUE, 1, e->fancy_name, 2, e, -1); } diff --git a/hardinfo2/uidefs.h b/hardinfo2/uidefs.h index f384504b..75549f35 100644 --- a/hardinfo2/uidefs.h +++ b/hardinfo2/uidefs.h @@ -27,6 +27,8 @@ char *uidefs_str = "<ui>" \ "<menuitem name=\"WebPage\" action=\"HomePageAction\"/>" \ "<menuitem name=\"ReportBug\" action=\"ReportBugAction\"/>" \ "<separator/>" \ +"<menuitem name=\"Donate\" action=\"DonateAction\"/>" \ +"<separator/>" \ "<menu name=\"HelpMenuModules\" action=\"HelpMenuModulesAction\">" \ "<separator name=\"LastSep\"/>" \ "</menu>" \ diff --git a/hardinfo2/uidefs.xml b/hardinfo2/uidefs.xml deleted file mode 100644 index 4ff878e2..00000000 --- a/hardinfo2/uidefs.xml +++ /dev/null @@ -1,42 +0,0 @@ -<ui> - <menubar> - <menu name="InformationMenu" action="InformationMenuAction"> - <menuitem name="Report" action="ReportAction" /> - <separator/> - <menuitem name="Copy" action="CopyAction" /> - <menuitem name="SaveGraph" action="SaveGraphAction" /> - <separator/> - <menuitem name="SyncManager" action="SyncManagerAction" /> - <separator/> - <menuitem name="Quit" action="QuitAction" /> - </menu> - <menu name="ViewMenu" action="ViewMenuAction"> - <menuitem name="SidePane" action="SidePaneAction"/> - <menuitem name="Toolbar" action="ToolbarAction"/> - <separator/> - <menuitem name="Refresh" action="RefreshAction"/> - <separator/> - <separator name="LastSep"/> - </menu> - <menu name="HelpMenu" action="HelpMenuAction"> - <menuitem name="OnlineDocs" action="OnlineDocsAction"/> - <separator/> - <menuitem name="WebPage" action="HomePageAction"/> - <menuitem name="ReportBug" action="ReportBugAction"/> - <separator/> - <menu name="HelpMenuModules" action="HelpMenuModulesAction"> - <separator name="LastSep"/> - </menu> - <menuitem name="About" action="AboutAction"/> - </menu> - </menubar> - - <toolbar action="MainMenuBar" action="MainMenuBarAction"> - <placeholder name="ToolItems"> - <toolitem name="Refresh" action="RefreshAction"/> - <separator/> - <toolitem name="Copy" action="CopyAction"/> - <toolitem name="Report" action="ReportAction"/> - </placeholder> - </toolbar> -</ui> diff --git a/hardinfo2/util.c b/hardinfo2/util.c index 265ebd3a..713e2c6f 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -206,6 +206,8 @@ gboolean binreloc_init(gboolean try_hardcoded) GError *error = NULL; gchar *tmp; + DEBUG("initializing binreloc (hardcoded = %d)", try_hardcoded); + /* If the runtime data directories we previously found, don't even try to find them again. */ if (params.path_data && params.path_lib) { @@ -394,6 +396,8 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param) gboolean ui_init(int *argc, char ***argv) { + DEBUG("initializing gtk+ UI"); + g_set_application_name("HardInfo"); g_log_set_handler(NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL | |