From 89f0dd1c94c08e6f6d972c23dff1a5e40ba5d0e5 Mon Sep 17 00:00:00 2001 From: b0ric Date: Mon, 3 Aug 2009 15:59:50 +0300 Subject: WordExtract GUI prototype --- main.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index e944736..349942d 100644 --- a/main.c +++ b/main.c @@ -17,9 +17,11 @@ */ #include +#include #include #include #include +#include "interface.h" #include "dict.h" #include "word.h" #include "subtitle.h" @@ -35,21 +37,14 @@ void create_dict_file(char *path); int main(int argc, char *argv[]) { + GtkWidget *main_window; FILE *subtitle; FILE *fdict; char optpath[PATH_LENGTH] = {0}; char dictfile[PATH_LENGTH] = {0}; - if (argc == 2) { - if (!(subtitle = fopen(argv[1], "r"))) { - perror(argv[1]); - exit(1); - } - } - else { - printf("Usage: %s \n", argv[0]); - exit(1); - } + gtk_init(&argc, &argv); + strcpy(optpath, getenv("HOME")); strcat(optpath, OPT_FOLDER); strcat(dictfile, optpath); @@ -63,12 +58,23 @@ int main(int argc, char *argv[]) } } dict = load_dict(fdict); + lang = ENG; + + main_window = create_main_window(); + gtk_widget_show(main_window); + + /*main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(main_window), "WordExtract"); + gtk_window_set_default_size(GTK_WINDOW(main_window), 800, 600); + gtk_window_set_position(GTK_WINDOW(main_window), GTK_WIN_POS_CENTER); + gtk_widget_show(main_window);*/ + + gtk_main(); //TODO: process subtitle extension to detect format - lang = ENG; - process_srt(subtitle); - print_words(words); - fclose(subtitle); + //process_srt(subtitle); + //print_words(words); + //fclose(subtitle); free_words(dict); fclose(fdict); return 0; @@ -82,7 +88,7 @@ void create_dict_file(char *path) char file[PATH_LENGTH] = {0}; if (stat(path, &st)) { - fprintf(stdout, "%s: Creating directory\n", path); + fprintf(stderr, "%s: Creating directory\n", path); if (mkdir(path, mode_0755)) { perror(path); exit(1); @@ -90,7 +96,7 @@ void create_dict_file(char *path) } strcat(file, path); strcat(file, DICT_FILE); - fprintf(stdout, "%s: Creating blank dictionary file\n", file); + fprintf(stderr, "%s: Creating blank dictionary file\n", file); if (!(fdict = fopen(file, "w"))) { perror(file); exit(1); -- cgit v1.2.3