mirror of
git://projects.qi-hardware.com/vido.git
synced 2024-12-22 14:48:57 +02:00
remove temp file
Signed-off-by: Mirko Lindner <mirko@qi-hardware.com>
This commit is contained in:
parent
a025d15ca3
commit
a138d4b770
159
src/vido.cc~
159
src/vido.cc~
@ -1,159 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Mirko Lindner,,, *
|
||||
* vegyraupe@mira *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <zim/file.h>
|
||||
#include <zim/fileiterator.h>
|
||||
#include <zim/search.h>
|
||||
#include <zim/articlesearch.h>
|
||||
#include "main_window.hh"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
extern "C" {
|
||||
#include "gtkhtml/gtkhtml.h"
|
||||
}
|
||||
|
||||
using namespace Gtk;
|
||||
Glib::RefPtr<Gtk::TextBuffer> buffer;
|
||||
unsigned int seed = static_cast<unsigned int>(time(0));
|
||||
zim::Search::Results result;
|
||||
std::string res;
|
||||
std::string content;
|
||||
std::string file;
|
||||
zim::File f;
|
||||
|
||||
Widget *html;
|
||||
GtkWidget *html_wg;
|
||||
|
||||
void set_article(std::string txt)
|
||||
{
|
||||
content = txt;
|
||||
}
|
||||
|
||||
void show_random(){
|
||||
|
||||
while(true){
|
||||
zim::File m(file);
|
||||
zim::size_type idx = static_cast<zim::size_type>(static_cast<double>(m.getCountArticles()) * rand_r(&seed) / RAND_MAX);
|
||||
|
||||
zim::Article article = m.getArticle(idx);
|
||||
|
||||
std::string res = article.getPage(false, 10);
|
||||
std::cout<<"Diese Zeile läuft so lange bis "<<res.size()<<".";
|
||||
if (res.size() > 0){
|
||||
set_article(res);
|
||||
break;
|
||||
}
|
||||
}
|
||||
std::cout<<"nach while "<<content.size()<<".";
|
||||
gtk_html_flush(GTK_HTML(html_wg));
|
||||
gtk_html_load_from_string(GTK_HTML(html_wg), content.c_str(), -1);
|
||||
// gtk_html_set_editable(GTK_HTML(html_wg),false);
|
||||
// gtk_html_allow_selection(GTK_HTML(html_wg),true);
|
||||
// gtk_html_set_magic_links(GTK_HTML(html_wg),true);
|
||||
// gtk_html_set_caret_mode(GTK_HTML(html_wg),true);
|
||||
|
||||
}
|
||||
|
||||
void set_html(const gchar *url){
|
||||
// std::cout<<"url"<<url<<".";
|
||||
zim::File m(file);
|
||||
|
||||
zim::Search::Results result;
|
||||
result.clear();
|
||||
zim::Search search(m);
|
||||
std::string term;
|
||||
term.assign( url );
|
||||
search.search(result, term);
|
||||
std::cout<<"url"<<result.size()<<".";
|
||||
if (!result.empty()){
|
||||
zim::Article article = m.getArticle(result[0].getArticle().getIndex());
|
||||
|
||||
std::string content = article.getPage(false, 10);
|
||||
|
||||
gtk_html_flush(GTK_HTML(html_wg));
|
||||
gtk_html_load_from_string(GTK_HTML(html_wg), content.c_str(), -1);
|
||||
}
|
||||
}
|
||||
|
||||
void set_berlin(){
|
||||
// std::cout<<"url"<<url<<".";
|
||||
zim::File m(file);
|
||||
|
||||
zim::Search::Results result;
|
||||
result.clear();
|
||||
zim::Search search(m);
|
||||
std::string term = "Geographische+Koordinaten";
|
||||
// term.assign( url );
|
||||
search.search(result, term);
|
||||
if (result.size() > 0){
|
||||
zim::Article article = m.getArticle(result[0].getArticle().getIndex());
|
||||
|
||||
std::string content = article.getPage(false, 10);
|
||||
|
||||
gtk_html_flush(GTK_HTML(html_wg));
|
||||
gtk_html_load_from_string(GTK_HTML(html_wg), content.c_str(), -1);
|
||||
}
|
||||
|
||||
// std::cout<<"url"<<<<".";
|
||||
}
|
||||
|
||||
bool on_link_clicked(GtkHTML *html, const gchar *url)
|
||||
{
|
||||
|
||||
set_html(url);
|
||||
// set_berlin();
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
file = argv[1];
|
||||
|
||||
Main kit(argc, argv);
|
||||
|
||||
main_window window;
|
||||
window.set_title("Wiki Viewer");
|
||||
window.set_border_width(0);
|
||||
window.set_default_size(320, 240);
|
||||
// window.set_resizable(0);
|
||||
|
||||
html_wg = gtk_html_new();
|
||||
|
||||
html = Glib::wrap(html_wg);
|
||||
g_signal_connect( G_OBJECT( html_wg ), "link_clicked", G_CALLBACK( on_link_clicked ), NULL );
|
||||
|
||||
ScrolledWindow scrolled_window;
|
||||
|
||||
scrolled_window.add(*html);
|
||||
scrolled_window.set_policy(POLICY_NEVER, POLICY_AUTOMATIC);
|
||||
|
||||
window.add(scrolled_window);
|
||||
window.show_all();
|
||||
|
||||
show_random();
|
||||
// set_berlin();
|
||||
Main::run(window);
|
||||
return 0;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user