From e161d10e627c8d0bcd2c41257c0afe5a19ec5b24 Mon Sep 17 00:00:00 2001 From: Mirko Lindner Date: Sun, 20 Dec 2009 20:12:23 +0100 Subject: [PATCH] load file only once; check for argument count, if not 2 show message Signed-off-by: Mirko Lindner --- src/vido.cc | 88 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/src/vido.cc b/src/vido.cc index e2e1483..e8d4b80 100644 --- a/src/vido.cc +++ b/src/vido.cc @@ -49,8 +49,24 @@ Window *window; Widget *html; GtkWidget *html_wg; +static zim::File zimFile; +static bool initialized = false; + // // // misc functions +const zim::File get_file() +{ + if (!initialized){ + std::cout<<"file not initialized :"<(static_cast(m.getCountArticles()) * rand_r(&seed) / RAND_MAX); zim::Article article = m.getArticle(idx); @@ -92,7 +112,7 @@ void search_window(main_window *window_x){ void set_html(const gchar *url){ // // create ZIM file accessor - zim::File m(file); + zim::File m = get_file(); // // convert url to string std::string term; @@ -156,7 +176,7 @@ void set_html(const gchar *url){ // // test functions void set_search(const gchar *url){ // std::cout<<"url"<getUrl() << '\n'; @@ -235,36 +255,44 @@ bool on_link_clicked(GtkHTML *html, const gchar *url) // // main function int main(int argc, char **argv) { + if (argc == 2) + { + file = argv[1]; - file = argv[1]; + std::cout<<"vido is here file:"<