diff options
| author | Burt P <pburt0@gmail.com> | 2017-07-20 07:35:55 -0500 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2017-07-30 10:09:27 -0700 | 
| commit | 86f2267b01dcb5ffbfb8e6fb90bba4d2e55cc84a (patch) | |
| tree | 03399cca4a693b7ab29c4cd2e298a889c3c3bdfc /modules | |
| parent | 7f59e9418e1d02c8223d9a874ae71aba1f66f02e (diff) | |
benchmark.c: break column headers out of format strings
* More easily translated.
* The strings are more likely to be re-usable.
* A small change to one, or to a shell param, does not lose all
  of them.
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/benchmark.c | 75 | 
1 files changed, 40 insertions, 35 deletions
| diff --git a/modules/benchmark.c b/modules/benchmark.c index 560e9f19..d24ecb41 100644 --- a/modules/benchmark.c +++ b/modules/benchmark.c @@ -197,23 +197,23 @@ static gchar *__benchmark_include_results(gdouble result,      path = g_build_filename(g_get_home_dir(), ".hardinfo", "benchmark.conf", NULL);      if (!g_file_test(path, G_FILE_TEST_EXISTS)) { -	DEBUG("local benchmark.conf not found, trying system-wide"); -	g_free(path); -	path = g_build_filename(params.path_data, "benchmark.conf", NULL); +        DEBUG("local benchmark.conf not found, trying system-wide"); +        g_free(path); +        path = g_build_filename(params.path_data, "benchmark.conf", NULL);      }      g_key_file_load_from_file(conf, path, 0, NULL);      machines = g_key_file_get_keys(conf, benchmark, NULL, NULL);      for (i = 0; machines && machines[i]; i++) { -	gchar *value, *cleaned_machine; +        gchar *value, *cleaned_machine; -	value   = g_key_file_get_value(conf, benchmark, machines[i], NULL); -	cleaned_machine = clean_cpuname(machines[i]); -	results = h_strconcat(results, cleaned_machine, "=", value, "\n", NULL); +        value   = g_key_file_get_value(conf, benchmark, machines[i], NULL); +        cleaned_machine = clean_cpuname(machines[i]); +        results = h_strconcat(results, cleaned_machine, "=", value, "\n", NULL); -	g_free(value); -	g_free(cleaned_machine); +        g_free(value); +        g_free(cleaned_machine);      }      g_strfreev(machines); @@ -222,29 +222,34 @@ static gchar *__benchmark_include_results(gdouble result,      if (result > 0.0f) {          processor_frequency = module_call_method("devices::getProcessorFrequency"); -        return_value = g_strdup_printf(_("[$ShellParam$]\n" -			       	   "Zebra=1\n" -			       	   "OrderType=%d\n" -	       			   "ViewType=3\n" -	       			   "ColumnTitle$Extra1=CPU Clock\n" -			       	   "ColumnTitle$Progress=Results\n" -			       	   "ColumnTitle$TextValue=CPU\n" -			       	   "ShowColumnHeaders=true\n" -	       			   "[%s]\n" -		       		   "<big><b>This Machine</b></big>=%.3f|%s MHz\n" -			       	   "%s"), order_type, benchmark, result, processor_frequency, results); +        return_value = g_strdup_printf("[$ShellParam$]\n" +                       "Zebra=1\n" +                       "OrderType=%d\n" +                       "ViewType=3\n" +                       "ColumnTitle$Extra1=%s\n" /* CPU Clock */ +                       "ColumnTitle$Progress=%s\n" /* Results */ +                       "ColumnTitle$TextValue=%s\n" /* CPU */ +                       "ShowColumnHeaders=true\n" +                       "[%s]\n" +                       "<big><b>This Machine</b></big>=%.3f|%s MHz\n" +                       "%s", order_type, +                       _("CPU Clock"), _("Results"), _("CPU"), +                       benchmark, +                       result, processor_frequency, results);          g_free(processor_frequency);      } else { -        return_value = g_strdup_printf(_("[$ShellParam$]\n" -			       	   "Zebra=1\n" -			       	   "OrderType=%d\n" -	       			   "ViewType=3\n" -	       			   "ColumnTitle$Extra1=CPU Clock\n" -			       	   "ColumnTitle$Progress=Results\n" -			       	   "ColumnTitle$TextValue=CPU\n" -			       	   "ShowColumnHeaders=true\n" -	       			   "[%s]\n" -			       	   "%s"), order_type, benchmark, results); +        return_value = g_strdup_printf("[$ShellParam$]\n" +                       "Zebra=1\n" +                       "OrderType=%d\n" +                       "ViewType=3\n" +                       "ColumnTitle$Extra1=%s\n" /* CPU Clock */ +                       "ColumnTitle$Progress=%s\n" /* Results */ +                       "ColumnTitle$TextValue=%s\n" /* CPU */ +                       "ShowColumnHeaders=true\n" +                       "[%s]\n%s", +                       order_type, +                       _("CPU Clock"), _("Results"), _("CPU"), +                       benchmark, results);      }      return return_value;  } @@ -357,7 +362,7 @@ static gboolean do_benchmark_handler(GIOChannel *source,  static void do_benchmark(void (*benchmark_function)(void), int entry)  {      int old_priority = 0; -     +      if (params.gui_running && !sending_benchmark_results) {         gchar *argv[] = { params.argv0, "-b", entries[entry].name,                           "-m", "benchmark.so", "-a", NULL }; @@ -373,7 +378,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)         shell_view_set_enabled(FALSE);         shell_status_update(bench_status); -        +         g_free(bench_status);         bench_image = icon_cache_get_image("benchmark.png"); @@ -397,7 +402,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)         benchmark_dialog = g_new0(BenchmarkDialog, 1);         benchmark_dialog->dialog = bench_dialog;         benchmark_dialog->result = -1.0f; -        +         if (!g_path_is_absolute(params.argv0)) {            spawn_flags |= G_SPAWN_SEARCH_PATH;         } @@ -441,7 +446,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)            return;         } -        +         gtk_widget_destroy(bench_dialog);         g_free(benchmark_dialog);         shell_status_set_enabled(TRUE); @@ -612,7 +617,7 @@ static gchar *get_benchmark_results()      g_free(machineram);      sending_benchmark_results = FALSE; -     +      return result;  } | 
