From 6575416e6005682af2f843992dd3e2f2a596b241 Mon Sep 17 00:00:00 2001 From: Mirko Lindner Date: Fri, 30 Oct 2009 12:17:56 +0100 Subject: [PATCH] create search function function works in general but needs refining, again several articles returned etc Signed-off-by: Mirko Lindner --- src/main_window.cc | 3 ++- src/main_window.hh | 1 + src/search_dialog.cc | 50 ++++++++++++++++++++++++++++++++++++++++++++ src/search_dialog.hh | 34 ++++++++++++++++++++++++++++++ src/vido.cc | 15 +++++++++---- 5 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 src/search_dialog.cc create mode 100644 src/search_dialog.hh diff --git a/src/main_window.cc b/src/main_window.cc index 3117715..b803f0b 100644 --- a/src/main_window.cc +++ b/src/main_window.cc @@ -28,6 +28,7 @@ extern void show_random(); +extern void search_window(main_window *window); main_window::main_window() { @@ -62,7 +63,7 @@ bool main_window::actions(int key) } else if(key == int(115)) { - + search_window(this); printf("search"); } diff --git a/src/main_window.hh b/src/main_window.hh index 3a9bc97..123cc98 100644 --- a/src/main_window.hh +++ b/src/main_window.hh @@ -33,6 +33,7 @@ class main_window : public Gtk::Window ~main_window(); bool actions(int); int ctrl_state; +// void search_dialog(); private: bool on_my_key_press_event(GdkEventKey *event); diff --git a/src/search_dialog.cc b/src/search_dialog.cc new file mode 100644 index 0000000..2a062cc --- /dev/null +++ b/src/search_dialog.cc @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2009 by Mirko Lindner * + * mirko@qi-hardware.com * + * * + * 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 "config.h" +#include "search_dialog.hh" +#include + +extern void set_html(const gchar *url); + +search_dialog::search_dialog(main_window* parent, Glib::ustring input="") +{ + Gtk::Dialog dialog("Search", parent, true); + + Gtk::Label label("Enter search Term:"); + dialog.get_vbox()->pack_start(label, true, true); + Gtk::Entry entry; + entry.set_text(""); + dialog.get_vbox()->pack_start(entry, true, true); + + dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); + dialog.show_all(); + int result = dialog.run(); + if (result == Gtk::RESPONSE_OK) { + set_html(entry.get_text().c_str()); + } else { + + } + +} + + search_dialog::~search_dialog() +{ } \ No newline at end of file diff --git a/src/search_dialog.hh b/src/search_dialog.hh new file mode 100644 index 0000000..ff8632e --- /dev/null +++ b/src/search_dialog.hh @@ -0,0 +1,34 @@ +/*************************************************************************** + * Copyright (C) 2009 by Mirko Lindner * + * mirko@qi-hardware.com * + * * + * 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 +// #include +#include +#include + +extern main_window parent; + +class search_dialog : public Gtk::Dialog{ + + public: + search_dialog(main_window* parent, Glib::ustring); + ~search_dialog(); + +}; \ No newline at end of file diff --git a/src/vido.cc b/src/vido.cc index cdaee23..dd27757 100644 --- a/src/vido.cc +++ b/src/vido.cc @@ -24,12 +24,14 @@ #include #include #include -#include "main_window.hh" #include #include #include +// #include "main_window.hh" +#include "search_dialog.hh" + extern "C" { #include "gtkhtml/gtkhtml.h" } @@ -42,6 +44,7 @@ std::string res; std::string content; std::string file; zim::File f; +Window *window; Widget *html; GtkWidget *html_wg; @@ -66,17 +69,22 @@ void show_random(){ zim::Article article = m.getArticle(idx); std::string res = article.getPage(false, 10); -// std::cout<<"Diese Zeile läuft so lange bis "< 0){ set_article(res); break; } } -// std::cout<<"nach while "<