19 |
|
|
20 |
#include <gtk/gtk.h> |
#include <gtk/gtk.h> |
21 |
#include <stdio.h> |
#include <stdio.h> |
22 |
|
#include <string.h> |
23 |
|
|
24 |
#include "gui_helpdialog.h" |
#include "gui_helpdialog.h" |
25 |
#include "support.h" |
#include "support.h" |
29 |
static void open_help (gchar *filename) |
static void open_help (gchar *filename) |
30 |
{ |
{ |
31 |
GtkWidget *helpdialog, *helptextview, *scrolledwindow, *ok_button; |
GtkWidget *helpdialog, *helptextview, *scrolledwindow, *ok_button; |
32 |
gchar buf[80], *helpfile, *title; |
gchar *buf, fbuf[80], *helpfile, *title; |
33 |
FILE *in; |
FILE *in; |
34 |
GtkTextBuffer *buffer; |
GtkTextBuffer *buffer; |
35 |
GtkTextIter iter; |
GtkTextIter iter; |
36 |
gint response; |
gint response; |
37 |
|
GError *err; |
38 |
|
|
39 |
title = g_strdup_printf ("xlog - %s", filename); |
title = g_strdup_printf ("xlog - %s", filename); |
40 |
helpdialog = gtk_dialog_new_with_buttons (title, |
helpdialog = gtk_dialog_new_with_buttons (title, |
63 |
gtk_text_buffer_create_tag (buffer, "italic", "style", PANGO_STYLE_ITALIC, NULL); |
gtk_text_buffer_create_tag (buffer, "italic", "style", PANGO_STYLE_ITALIC, NULL); |
64 |
gtk_text_buffer_create_tag (buffer, "blue", "foreground", "blue", NULL); |
gtk_text_buffer_create_tag (buffer, "blue", "foreground", "blue", NULL); |
65 |
|
|
66 |
|
buf = g_new0 (gchar, 100); |
67 |
in = fopen (helpfile, "r"); |
in = fopen (helpfile, "r"); |
68 |
if (in) |
if (in) |
69 |
{ |
{ |
70 |
do |
do |
71 |
{ |
{ |
72 |
if (fgets (buf, 80, in) == NULL) |
if (fgets (fbuf, 80, in) == NULL) |
73 |
break; |
break; |
74 |
else |
else |
75 |
{ |
{ |
76 |
|
if (!g_utf8_validate (fbuf, -1, NULL )) |
77 |
|
{ |
78 |
|
err = NULL; |
79 |
|
buf = g_locale_to_utf8 (fbuf, -1, NULL, NULL, &err); |
80 |
|
if (err) |
81 |
|
{ |
82 |
|
g_warning (_("Unable to convert '%s' to UTF-8: %s"), |
83 |
|
fbuf, err->message); |
84 |
|
g_error_free (err); |
85 |
|
} |
86 |
|
} |
87 |
|
else |
88 |
|
buf = g_strdup (fbuf); |
89 |
if (buf[0] == '-') |
if (buf[0] == '-') |
90 |
gtk_text_buffer_insert_with_tags_by_name |
gtk_text_buffer_insert_with_tags_by_name |
91 |
(buffer, &iter, buf, -1, "bold", NULL); |
(buffer, &iter, buf, -1, "bold", NULL); |
106 |
|
|
107 |
fclose (in); |
fclose (in); |
108 |
} |
} |
109 |
|
g_free (buf); |
110 |
g_free (helpfile); |
g_free (helpfile); |
111 |
|
|
112 |
gtk_widget_show_all (helpdialog); |
gtk_widget_show_all (helpdialog); |
113 |
response = gtk_dialog_run (GTK_DIALOG(helpdialog)); |
response = gtk_dialog_run (GTK_DIALOG(helpdialog)); |
114 |
gtk_widget_destroy (helpdialog); |
gtk_widget_destroy (helpdialog); |