First step for a GTK version
[xboard.git] / interface.c
1 #include "config.h"
2
3 #include <stdio.h>
4 #include <ctype.h>
5 #include <signal.h>
6 #include <errno.h>
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <pwd.h>
10
11 #include <gtk/gtk.h>
12 #include <gdk-pixbuf/gdk-pixbuf.h>
13
14 #include "common.h"
15 #include "frontend.h"
16 #include "backend.h"
17 #include "moves.h"
18 #include "xboard.h"
19 #include "childio.h"
20 #include "xgamelist.h"
21 #include "xhistory.h"
22 #include "xedittags.h"
23 #include "gettext.h"
24 #include "callback.h"
25
26 #ifdef ENABLE_NLS
27 # define  _(s) gettext (s)
28 # define N_(s) gettext_noop (s)
29 #else
30 # define  _(s) (s)
31 # define N_(s)  s
32 #endif
33
34
35
36 GdkPixbuf *load_pixbuf(char *filename)
37 {
38   GdkPixbuf *image;
39
40   image = gdk_pixbuf_new_from_file(filename,NULL);
41
42   if(image == NULL)
43     {
44       fprintf(stderr,_("Error: couldn't load file: %s\n"),filename);
45       exit(1);
46     }
47   return image;
48 }
49
50 void GUI_DisplayTitle(text)
51      char *text;
52 {
53     char title[MSG_SIZ];
54     extern GtkWidget *GUI_Window;
55
56     if (text == NULL) text = "";
57
58     /* todo
59     if (appData.titleInWindow) {
60         i = 0;
61         XtSetArg(args[i], XtNlabel, text);   i++;
62         XtSetValues(titleWidget, args, i);
63         } */
64
65     if (*text != NULLCHAR) {
66         strcpy(title, text);
67     } else if (appData.icsActive) {
68         sprintf(title, "%s: %s", programName, appData.icsHost);
69     } else if (appData.cmailGameName[0] != NULLCHAR) {
70         sprintf(title, "%s: %s", programName, "CMail");
71     } else if (appData.noChessProgram) {
72         strcpy(title, programName);
73     } else {
74         sprintf(title, "%s: %s", programName, first.tidy);
75     }
76     gtk_window_set_title(GTK_WINDOW(GUI_Window),title);
77 }