~ubuntu-branches/ubuntu/breezy/tiemu/breezy

« back to all changes in this revision

Viewing changes to src/gui/gtk/thanks_cb.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien BLACHE
  • Date: 2005-06-02 16:50:15 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050602165015-59ab24414tl2wzol
Tags: 1.99+svn1460-1
* New snapshot.
* debian/control:
  + Updated build-depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifdef HAVE_CONFIG_H
2
 
#  include <config.h>
3
 
#endif
4
 
 
5
 
#include <gtk/gtk.h>
6
 
 
7
 
#include "thanks_cb.h"
8
 
#include "thanks_dbox.h"
9
 
#include "support.h"
10
 
 
11
 
#include "tilibs.h"
12
 
#include "platform.h"
13
 
#include "struct.h"
14
 
#include "ticalc.h"
15
 
#include "paths.h"
16
 
#include "files.h"
17
 
#include "main.h"
18
 
 
19
 
gint display_thanks_dbox()
20
 
{
21
 
  GtkWidget *dbox;
22
 
  gpointer user_data;
23
 
  FILE *fd;
24
 
  gchar *buffer;
25
 
  GdkFont *fixed_font;
26
 
  GtkWidget *text;
27
 
 
28
 
  dbox = create_thanks_dbox();
29
 
  
30
 
  user_data = gtk_object_get_data(GTK_OBJECT(dbox), "text1");
31
 
  text = GTK_WIDGET(user_data);
32
 
  gtk_editable_delete_text(GTK_EDITABLE(text), 0, -1);
33
 
 
34
 
  /* Create the base filename */
35
 
#if defined(__LINUX__)
36
 
  buffer = g_strconcat(inst_paths.base_dir, SHARE_DIR, DIR_SEPARATOR,
37
 
                       "THANKS", NULL);
38
 
#elif defined(__WIN32__)
39
 
  buffer = g_strconcat(inst_paths.base_dir, SHARE_DIR, DIR_SEPARATOR,
40
 
                       "Thanks.txt", NULL);
41
 
#endif  
42
 
 
43
 
  /* Try to access the file */
44
 
  if(access(buffer, F_OK) == 0 )
45
 
    {
46
 
#if defined(__LINUX__)
47
 
      fixed_font = gdk_font_load ("-misc-clean-medium-r-*-*-*-140-*-*-*-*-*-*");
48
 
#elif defined(__WIN32__)
49
 
      fixed_font = gdk_font_load ("-adobe-courier-medium-r-normal--12-120-75-75-p-70-iso8859-1");
50
 
#endif
51
 
      if( (fd=fopen (buffer, "r")) != NULL)
52
 
        {
53
 
          memset (buffer, 0, sizeof(buffer));
54
 
          while(fread (buffer, 1, sizeof(buffer)-1, fd))
55
 
            {
56
 
              process_buffer(buffer);
57
 
              gtk_text_insert (GTK_TEXT (text), fixed_font, NULL, NULL, buffer, strlen (buffer));
58
 
              memset (buffer, 0, sizeof(buffer));
59
 
            }
60
 
          fclose (fd);
61
 
        }
62
 
    }
63
 
  
64
 
  g_free(buffer);
65
 
  gtk_widget_show_all(dbox);
66
 
  return 0;
67
 
}
68
 
 
69
 
 
70
 
void
71
 
thanks_ok_button_clicked                     (GtkButton       *button,
72
 
                                        gpointer         user_data)
73
 
{
74
 
  gtk_widget_destroy(GTK_WIDGET(user_data));
75
 
  unhalt();
76
 
}