/[xlog]/xlog/src/gui_helpdialog.c
ViewVC logotype

Diff of /xlog/src/gui_helpdialog.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by pa4tu, Thu Feb 10 18:34:11 2005 UTC revision 1.15 by pa4tu, Thu Feb 10 19:02:08 2005 UTC
# Line 19  Line 19 
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"
# Line 28  extern GtkWidget *mainwindow; Line 29  extern GtkWidget *mainwindow;
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,
# Line 61  static void open_help (gchar *filename) Line 63  static void open_help (gchar *filename)
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);
# Line 90  static void open_help (gchar *filename) Line 106  static void open_help (gchar *filename)
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);

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26