1 /*
2  *  This program is free software; you can redistribute it and/or modify
3  *  it under the terms of the GNU General Public License as published by
4  *  the Free Software Foundation; either version 2 of the License, or
5  *  (at your option) any later version.
6  *
7  *  This program is distributed in the hope that it will be useful,
8  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  *  GNU Library General Public License for more details.
11  *
12  *  You should have received a copy of the GNU General Public License
13  *  along with this program; if not, write to the Free Software
14  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */
16 #include "gtk_main-server.h"
17 #include "interface-server.h"
18 #include "config.h"
19 
20 GtkWidget* window_main;
21 GtkWidget* window_help;
22 gboolean gtk_stop_asked;
23 
24 //! Construct the gtk interface
build_gtk_interface(int argc,char * argv[])25 void build_gtk_interface (int argc, char* argv[])
26 {
27 
28   gtk_set_locale ();
29   gtk_init (&argc, &argv);
30 
31   add_pixmap_directory (".");
32   add_pixmap_directory ("/usr/share/hugo/pixmaps");
33   add_pixmap_directory (PACKAGE_DATA_DIR "/pixmaps");
34   add_pixmap_directory ("./pixmaps");
35 
36   window_main = create_window_main();
37   window_help = create_window_help();
38 
39   gtk_widget_show (window_main);
40 
41   gtk_main ();
42 }
43 
44 //! Append string to the buffer
printf_screen(char * format,...)45 void printf_screen (char *format, ...)
46 {
47   char buf[256];
48   GtkTextView* textview_status = NULL;
49   GtkTextMark* insert_mark = NULL;
50 
51   va_list ap;
52   va_start (ap, format);
53   vsprintf (buf, format, ap);
54   va_end (ap);
55 
56   if (window_main)
57     {
58       textview_status = (GtkTextView*) lookup_widget(window_main, "textview_status");
59       if (textview_status)
60 	{
61 	  gtk_text_buffer_insert_at_cursor(gtk_text_view_get_buffer(textview_status),
62 					   buf,
63 					   strlen(buf));
64 	  insert_mark = gtk_text_buffer_get_mark (gtk_text_view_get_buffer(textview_status),
65 						  "insert");
66 	  gtk_text_view_scroll_to_mark    (textview_status,
67 					   insert_mark,
68 					   0.0f,
69 					   FALSE,
70 					   0.0f,
71 					   0.0f);
72 	  return;
73 	}
74     }
75 
76   vprintf(format, ap);
77 
78 }
79