From 343357ed1e7907cf4b488058053df280ae63c7bb Mon Sep 17 00:00:00 2001 From: b0ric Date: Sat, 8 Aug 2009 20:18:38 +0300 Subject: Now words are shown in alphabetical order --- main.c | 61 +++++++++---------------------------------------------------- 1 file changed, 9 insertions(+), 52 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 79c744f..e5d9439 100644 --- a/main.c +++ b/main.c @@ -16,79 +16,36 @@ * along with this program. If not, see . */ -#include #include #include #include -#include "interface.h" -#include "subtitle.h" +#include "main.h" +#include "mainwin.h" #include "dict.h" -#define PROGNAME "wordextract" -#define OPT_FOLDER "/.wordextract" -#define PATH_LENGTH 50 - +char optpath[PATH_LENGTH] = {0}; +char dictfile[PATH_LENGTH] = {0}; Language lang; -static void create_dict_file(char *); -static void open_and_load_dict(); +static void fill_vars(); int main(int argc, char *argv[]) { - gtk_init(&argc, &argv); - open_and_load_dict(); + fill_vars(); + dict = load_dict(); lang = ENG; create_main_window(); gtk_widget_show(main_window); gtk_main(); - - free_words(dict); + free_words(dict); /*Where to put?*/ return 0; } -void create_dict_file(char *path) -{ - mode_t mode_0755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; - struct stat st; - FILE *fdict; - char file[PATH_LENGTH] = {0}; - - if (stat(path, &st)) { - fprintf(stderr, "%s: Creating directory\n", path); - if (mkdir(path, mode_0755)) { - perror(path); - exit(1); - } - } - strcat(file, path); - strcat(file, DICT_FILE); - fprintf(stderr, "%s: Creating blank dictionary file\n", file); - if (!(fdict = fopen(file, "w"))) { - perror(file); - exit(1); - } - fclose(fdict); -} - -void open_and_load_dict() +void fill_vars() { - FILE *fdict; - char optpath[PATH_LENGTH] = {0}; - char dictfile[PATH_LENGTH] = {0}; - strcpy(optpath, getenv("HOME")); strcat(optpath, OPT_FOLDER); strcat(dictfile, optpath); strcat(dictfile, DICT_FILE); - if (!(fdict = fopen(dictfile, "r"))) { - perror(dictfile); - create_dict_file(optpath); - if (!(fdict = fopen(dictfile, "r"))) { - perror(dictfile); - exit(1); - } - } - dict = load_dict(fdict); - fclose(fdict); } -- cgit v1.2.3