summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro A. F. Pereira <leandro@hardinfo.org>2007-10-21 15:24:14 +0000
committerLeandro A. F. Pereira <leandro@hardinfo.org>2007-10-21 15:24:14 +0000
commit90b5d774145be3f0929588b751c935e465cb5a44 (patch)
tree4c50b4fda92dfa8155213ad92fbe3a08d74308aa
parent20f10899a0018ffce790496cc87b4d51e68716f9 (diff)
Cleanups, plug memleaks in report generation, include UTF-8 content-type tag in HTML reports.
-rw-r--r--hardinfo2/report.c42
-rw-r--r--hardinfo2/shell.c26
2 files changed, 32 insertions, 36 deletions
diff --git a/hardinfo2/report.c b/hardinfo2/report.c
index a2b82c47..85653502 100644
--- a/hardinfo2/report.c
+++ b/hardinfo2/report.c
@@ -161,6 +161,7 @@ static void report_html_header(ReportContext * ctx)
g_strdup_printf
("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Final//EN\">\n"
"<html><head>\n" "<title>HardInfo (%s) System Report</title>\n"
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"
"<style>\n" " body { background: #fff }\n"
" .title { font: bold 130%% serif; color: #0066FF; padding: 30px 0 10px 0 }\n"
" .stitle { font: bold 100%% sans-serif; color: #0044DD; padding: 30px 0 10px 0 }\n"
@@ -173,40 +174,39 @@ static void report_html_header(ReportContext * ctx)
static void report_html_footer(ReportContext * ctx)
{
- ctx->output = g_strconcat(ctx->output,
+ ctx->output = h_strconcat(ctx->output,
"</tbody></table></body></html>", NULL);
}
static void report_html_title(ReportContext * ctx, gchar * text)
{
- ctx->output = g_strdup_printf("%s"
- "<tr><td colspan=\"2\" class=\"titl"
+ ctx->output = h_strdup_cprintf("<tr><td colspan=\"2\" class=\"titl"
"e\">%s</td></tr>\n", ctx->output, text);
}
static void report_html_subtitle(ReportContext * ctx, gchar * text)
{
- ctx->output = g_strdup_printf("%s"
- "<tr><td colspan=\"2\" class=\"stit"
+ ctx->output = h_strdup_cprintf("<tr><td colspan=\"2\" class=\"stit"
"le\">%s</td></tr>\n",
- ctx->output, text);
+ ctx->output,
+ text);
}
static void report_html_subsubtitle(ReportContext * ctx, gchar * text)
{
- ctx->output = g_strdup_printf("%s"
- "<tr><td colspan=\"2\" class=\"ssti"
+ ctx->output = h_strdup_cprintf("<tr><td colspan=\"2\" class=\"ssti"
"tle\">%s</td></tr>\n",
- ctx->output, text);
+ ctx->output,
+ text);
}
static void
report_html_key_value(ReportContext * ctx, gchar * key, gchar * value)
{
- ctx->output = g_strdup_printf("%s"
- "<tr><td class=\"field\">%s</td>"
+ ctx->output = h_strdup_cprintf("<tr><td class=\"field\">%s</td>"
"<td class=\"value\">%s</td></tr>\n",
- ctx->output, key, value);
+ ctx->output,
+ key, value);
}
static void report_text_header(ReportContext * ctx)
@@ -226,11 +226,11 @@ static void report_text_title(ReportContext * ctx, gchar * text)
gchar *str = (gchar *) ctx->output;
int i = strlen(text);
- str = g_strdup_printf("%s\n%s\n", str, text);
+ str = h_strdup_cprintf("\n%s\n", str, text);
for (; i; i--)
- str = g_strconcat(str, "*", NULL);
+ str = h_strconcat(str, "*", NULL);
- str = g_strconcat(str, "\n\n", NULL);
+ str = h_strconcat(str, "\n\n", NULL);
ctx->output = str;
}
@@ -239,17 +239,17 @@ static void report_text_subtitle(ReportContext * ctx, gchar * text)
gchar *str = ctx->output;
int i = strlen(text);
- str = g_strdup_printf("%s\n%s\n", str, text);
+ str = h_strdup_cprintf("\n%s\n", str, text);
for (; i; i--)
- str = g_strconcat(str, "-", NULL);
+ str = h_strconcat(str, "-", NULL);
- str = g_strconcat(str, "\n\n", NULL);
+ str = h_strconcat(str, "\n\n", NULL);
ctx->output = str;
}
static void report_text_subsubtitle(ReportContext * ctx, gchar * text)
{
- ctx->output = g_strdup_printf("%s-%s-\n", ctx->output, text);
+ ctx->output = h_strdup_cprintf("-%s-\n", ctx->output, text);
}
static void
@@ -257,9 +257,9 @@ report_text_key_value(ReportContext * ctx, gchar * key, gchar * value)
{
if (strlen(value))
ctx->output =
- g_strdup_printf("%s%s\t\t: %s\n", ctx->output, key, value);
+ h_strdup_cprintf("%s\t\t: %s\n", ctx->output, key, value);
else
- ctx->output = g_strdup_printf("%s%s\n", ctx->output, key);
+ ctx->output = h_strdup_cprintf("%s\n", ctx->output, key);
}
static GSList *report_create_module_list_from_dialog(ReportDialog * rd)
diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c
index 00d18be7..180dcc0e 100644
--- a/hardinfo2/shell.c
+++ b/hardinfo2/shell.c
@@ -929,9 +929,6 @@ moreinfo_handle_normal(GKeyFile * key_file, gchar * group, gchar ** keys)
}
}
-/* FIXME: This code must be rewritten. Although it works, it is *very* slow and
- too complex for this simple task. I am lazy, so I'm not fixing it.
- Be my guest to fix it. */
static void update_progress()
{
GtkTreeModel *model = shell->info->model;
@@ -1157,18 +1154,17 @@ static void module_selected(gpointer data)
gtk_tree_view_columns_autosize(GTK_TREE_VIEW(shell->info->view));
/* urgh. why don't GTK do this when the model is cleared? */
- gtk_range_set_value(GTK_RANGE
- (GTK_SCROLLED_WINDOW(shell->info->scroll)->
- vscrollbar), 0.0);
- gtk_range_set_value(GTK_RANGE
- (GTK_SCROLLED_WINDOW(shell->info->scroll)->
- hscrollbar), 0.0);
- gtk_range_set_value(GTK_RANGE
- (GTK_SCROLLED_WINDOW(shell->moreinfo->scroll)->
- vscrollbar), 0.0);
- gtk_range_set_value(GTK_RANGE
- (GTK_SCROLLED_WINDOW(shell->moreinfo->scroll)->
- hscrollbar), 0.0);
+#define RANGE_SET_VALUE(tree,scrollbar,value) \
+ gtk_range_set_value(GTK_RANGE \
+ (GTK_SCROLLED_WINDOW(shell->tree->scroll)-> \
+ scrollbar), value);
+
+ RANGE_SET_VALUE(info, vscrollbar, 0.0);
+ RANGE_SET_VALUE(info, hscrollbar, 0.0);
+ RANGE_SET_VALUE(moreinfo, vscrollbar, 0.0);
+ RANGE_SET_VALUE(moreinfo, hscrollbar, 0.0);
+
+#undef RANGE_SET_VALUE
shell_status_update("Done.");
shell_status_set_enabled(FALSE);