X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=interface.c;h=e1a2069208f5b2c095b27d922c113c9b2a7af77f;hb=3990747f9bf2f88dba5071eecadac28474edd293;hp=056a44e3eb6d12e936b8ab37225a960054f833fa;hpb=0acc60a8a75b095c69fbf9b8df8db37a4d522a6e;p=xboard.git diff --git a/interface.c b/interface.c index 056a44e..e1a2069 100644 --- a/interface.c +++ b/interface.c @@ -31,14 +31,18 @@ # define N_(s) s #endif +extern GtkWidget *GUI_Window; -GdkPixbuf *load_pixbuf(char *filename) +GdkPixbuf *load_pixbuf(char *filename,int size) { GdkPixbuf *image; - image = gdk_pixbuf_new_from_file(filename,NULL); - + if(size) + image = gdk_pixbuf_new_from_file_at_size(filename,size,size,NULL); + else + image = gdk_pixbuf_new_from_file(filename,NULL); + if(image == NULL) { fprintf(stderr,_("Error: couldn't load file: %s\n"),filename); @@ -47,31 +51,52 @@ GdkPixbuf *load_pixbuf(char *filename) 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; + + 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 + { + printf( "DEBUG: before call\n"); + /* TODO add indec */ + (*proc)(f, 0, filename); + printf( "DEBUG: after call\n"); + } + g_free (filename); + }; + + gtk_widget_destroy (dialog); + ModeHighlight(); + + return; - 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); }