X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=interface.c;h=5d7b5522a2cee85c6c1f0eb1e600696bca7d57c4;hb=66c168b845b3091bf8a616c3f23606efc36c6bf6;hp=05975a91e7a82c0e427fda56739f9879644cd716;hpb=00239ec86dbe7fa6e0f045991b40a5782690c152;p=xboard.git diff --git a/interface.c b/interface.c index 05975a9..5d7b552 100644 --- a/interface.c +++ b/interface.c @@ -1,3 +1,24 @@ +/* + * interface.c -- gtk-interface + * + * Copyright 2009, 2010 Free Software Foundation, Inc. + * + * GNU XBoard is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * GNU XBoard is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. * + * + *------------------------------------------------------------------------ + ** See the file ChangeLog for a revision history. */ + #include "config.h" #include @@ -31,6 +52,7 @@ # define N_(s) s #endif +extern GtkWidget *GUI_Window; GdkPixbuf *load_pixbuf(char *filename,int size) @@ -50,47 +72,50 @@ GdkPixbuf *load_pixbuf(char *filename,int size) return image; } -void GUI_DisplayTitle(text) - char *text; +void +FileNamePopUp(label, def, proc, openMode) + char *label; + char *def; + FileProc proc; + char *openMode; { - char title[MSG_SIZ]; - extern GtkWidget *GUI_Window; + /* TODO: + * implement look for certain file types + * use save/load button depending on what function is calling + */ - if (text == NULL) text = ""; + GtkWidget *dialog; - /* todo - if (appData.titleInWindow) { - i = 0; - XtSetArg(args[i], XtNlabel, text); i++; - XtSetValues(titleWidget, args, i); - } */ + dialog = gtk_file_chooser_dialog_new (label, + GTK_WINDOW(GUI_Window), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) + { + char *filename; + FILE *f; - if (*text != NULLCHAR) { - strcpy(title, text); - } else if (appData.icsActive) { - sprintf(title, "%s: %s", programName, appData.icsHost); - } else if (appData.cmailGameName[0] != NULLCHAR) { - sprintf(title, "%s: %s", programName, "CMail"); - } else if (appData.noChessProgram) { - strcpy(title, programName); - } else { - sprintf(title, "%s: %s", programName, first.tidy); - } - gtk_window_set_title(GTK_WINDOW(GUI_Window),title); -} + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); -void GUI_SetAspectRatio(ratio) - int ratio; -{ - /* sets the aspect ration of the main window */ - GdkGeometry hints; - extern GtkWidget *GUI_Window; + //see loadgamepopup + f = fopen(filename, openMode); + if (f == NULL) + { + DisplayError(_("Failed to open file"), errno); + } + else + { + /* TODO add indec */ + (*proc)(f, 0, filename); + } + g_free (filename); + }; + + gtk_widget_destroy (dialog); + ModeHighlight(); + + return; - hints.min_aspect = hints.max_aspect = ratio; - - gtk_window_set_geometry_hints (GTK_WINDOW (GUI_Window), - GTK_WIDGET (GUI_Window), - &hints, - GDK_HINT_ASPECT); - return; }