diff --git a/src/vido.cc b/src/vido.cc index b178c3a..d3177a5 100644 --- a/src/vido.cc +++ b/src/vido.cc @@ -52,7 +52,7 @@ Gtk::ScrolledWindow *scrolled_window2; Gtk::Widget *html; GtkWidget *html_wg; std::vector < std::pair< std::string, std::string > > history; -unsigned int position = 0; +int position; bool historyCall = false; // variable to keep url of currently displayed article std::string current_url = ""; @@ -65,12 +65,12 @@ const zim::File& get_file() if (!zimFile.good()) { - log_debug("file not initialized:" << fileName); +// log_debug("file not initialized:" << fileName); zimFile = zim::File(fileName); - log_debug("number of articles: " << zimFile.getCountArticles()); +// log_debug("number of articles: " << zimFile.getCountArticles()); } - log_debug("returning file."); +// log_debug("returning file."); return zimFile; } @@ -116,29 +116,41 @@ void show_help() // fill gtkhtml widget with new content void fill_gtkhtml(std::string& html_str, std::string url, std::string title){ - log_debug("fill gtkhtml called with " << url << " and " << title); + log_debug("fill gtkhtml called with " << position << " " << url << " and " << title); std::string ccontent; ccontent = "" + html_str; gtk_html_flush(GTK_HTML(html_wg)); gtk_html_load_from_string(GTK_HTML(html_wg), ccontent.c_str(), -1); current_url = url; if ((url != "") && title != ""){ - if (position == 0){ - log_debug("adding " << title << " to history"); + if ((!historyCall)){ + if(position != 0){ + std::vector < std::pair< std::string, std::string > >::iterator iterator = history.begin(); + log_debug("history size: " << history.size()); + for (int d=0; d < history.size(); d++){ + log_debug("history entry: " << d << " " << history[d].first); + } + for (int m=history.size()+position; m <= history.size(); m++){ + log_debug("erasing history: number: "<< m << "title: " << history[m].first); + history.erase(iterator+m); + } + } + log_debug("adding " << title << " to history \n" << "position: " << position); history.push_back( std::make_pair( url, title ) ); - if (history.size() == 11){ + if (history.size() == 11){ history.erase(history.begin()); } + log_debug("history size after stuff: " << history.size()); }else{ - if (!historyCall){ - log_debug("clearing history"); - std::vector < std::pair< std::string, std::string > >::iterator iterator = history.begin(); - for (int m=0; m < position; m++){ - history.erase(iterator+m); - } - }else{ +// if (!historyCall){ +// log_debug("clearing history"); +// std::vector < std::pair< std::string, std::string > >::iterator iterator = history.begin(); +// for (int m=0; m < position; m++){ +// history.erase(iterator+m); +// } +// }else{ historyCall = false; - } +// } } } @@ -157,10 +169,13 @@ void show_history() screenblock(1); std::string res, url, title; res += "