mirror of
git://projects.qi-hardware.com/vido.git
synced 2024-11-01 09:16:18 +02:00
create search function
function works in general but needs refining, again several articles returned etc Signed-off-by: Mirko Lindner <mirko@qi-hardware.com>
This commit is contained in:
parent
8e8144a4bb
commit
6575416e60
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
50
src/search_dialog.cc
Normal file
50
src/search_dialog.cc
Normal file
@ -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 <gtkmm.h>
|
||||
|
||||
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()
|
||||
{ }
|
34
src/search_dialog.hh
Normal file
34
src/search_dialog.hh
Normal file
@ -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 <gtkmm/dialog.h>
|
||||
// #include <gtkmm.h>
|
||||
#include <gtkmm/window.h>
|
||||
#include <main_window.hh>
|
||||
|
||||
extern main_window parent;
|
||||
|
||||
class search_dialog : public Gtk::Dialog{
|
||||
|
||||
public:
|
||||
search_dialog(main_window* parent, Glib::ustring);
|
||||
~search_dialog();
|
||||
|
||||
};
|
15
src/vido.cc
15
src/vido.cc
@ -24,12 +24,14 @@
|
||||
#include <zim/fileiterator.h>
|
||||
#include <zim/search.h>
|
||||
#include <zim/articlesearch.h>
|
||||
#include "main_window.hh"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
// #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 "<<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);
|
||||
}
|
||||
|
||||
// // display search dialog
|
||||
void search_window(main_window *window_x){
|
||||
|
||||
search_dialog(window_x, " ");
|
||||
|
||||
}
|
||||
|
||||
// // // meta functions
|
||||
|
||||
// // set displayed html to given url
|
||||
@ -186,7 +194,6 @@ bool on_link_clicked(GtkHTML *html, const gchar *url)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// // main function
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user