removed all my printf's for debugging
[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,int size)
37 {
38   GdkPixbuf *image;
39
40   if(size)
41     image = gdk_pixbuf_new_from_file_at_size(filename,size,size,NULL);
42   else
43     image = gdk_pixbuf_new_from_file(filename,NULL);
44   
45   if(image == NULL)
46     {
47       fprintf(stderr,_("Error: couldn't load file: %s\n"),filename);
48       exit(1);
49     }
50   return image;
51 }
52
53 void GUI_DisplayTitle(text)
54      char *text;
55 {
56     char title[MSG_SIZ];
57     extern GtkWidget *GUI_Window;
58
59     if (text == NULL) text = "";
60
61     /* todo
62     if (appData.titleInWindow) {
63         i = 0;
64         XtSetArg(args[i], XtNlabel, text);   i++;
65         XtSetValues(titleWidget, args, i);
66         } */
67
68     if (*text != NULLCHAR) {
69         strcpy(title, text);
70     } else if (appData.icsActive) {
71         sprintf(title, "%s: %s", programName, appData.icsHost);
72     } else if (appData.cmailGameName[0] != NULLCHAR) {
73         sprintf(title, "%s: %s", programName, "CMail");
74     } else if (appData.noChessProgram) {
75         strcpy(title, programName);
76     } else {
77         sprintf(title, "%s: %s", programName, first.tidy);
78     }
79     gtk_window_set_title(GTK_WINDOW(GUI_Window),title);
80 }
81
82 void GUI_SetAspectRatio(ratio)
83      int ratio;
84 {
85   /* sets the aspect ration of the main window */
86     GdkGeometry hints;
87     extern GtkWidget *GUI_Window;
88
89     hints.min_aspect = ratio;
90     hints.max_aspect = ratio;
91     
92     gtk_window_set_geometry_hints (GTK_WINDOW (GUI_Window),
93                                    GTK_WIDGET (GUI_Window),
94                                    &hints,
95                                    GDK_HINT_ASPECT);
96     return;
97 }