X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=interface.c;h=7d11a56cf4a4f84cdaf95a118425931b2b3c22eb;hb=7069f0a55d9aea7c11d798caec1a93bf35d4ad24;hp=b5381c9bfd883c7a84167b022a64c5ca0385930d;hpb=00f19ab354710c1f41deba65b92af335317b25e5;p=xboard.git diff --git a/interface.c b/interface.c index b5381c9..7d11a56 100644 --- a/interface.c +++ b/interface.c @@ -31,6 +31,7 @@ # define N_(s) s #endif +extern GtkWidget *GUI_Window; GdkPixbuf *load_pixbuf(char *filename,int size) @@ -50,19 +51,50 @@ GdkPixbuf *load_pixbuf(char *filename,int size) return image; } -void GUI_SetAspectRatio(ratio) - int ratio; +void +FileNamePopUp(label, def, proc, openMode) + char *label; + char *def; + FileProc proc; + char *openMode; { - /* sets the aspect ration of the main window */ - GdkGeometry hints; - extern GtkWidget *GUI_Window; + /* TODO: + * implement look for certain file types + * use save/load button depending on what function is calling + */ + + GtkWidget *dialog; + + 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; + + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + + //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 = ratio; - hints.max_aspect = ratio; - - gtk_window_set_geometry_hints (GTK_WINDOW (GUI_Window), - GTK_WIDGET (GUI_Window), - &hints, - GDK_HINT_ASPECT); - return; }