mirror of
git://projects.qi-hardware.com/vido.git
synced 2024-12-22 19:28:59 +02:00
make vido work again :)
Signed-off-by: Mirko Lindner <mirko@sharism.cc>
This commit is contained in:
parent
ffdd227df7
commit
f6d6448cfb
@ -1,8 +1,8 @@
|
|||||||
bin_PROGRAMS = vido
|
bin_PROGRAMS = vido
|
||||||
|
|
||||||
vido_SOURCES = main_window.cc search_dialog.cc vido.cc
|
vido_SOURCES = main_window.cc search_dialog.cc message_dialog.cc vido.cc
|
||||||
|
|
||||||
noinst_HEADERS = main_window.hh search_dialog.hh
|
noinst_HEADERS = main_window.hh search_dialog.hh message_dialog.hh
|
||||||
|
|
||||||
AM_CXXFLAGS = @CXXFLAGS@ @GTKMM_CFLAGS@ @GTKHTML_CFLAGS@
|
AM_CXXFLAGS = @CXXFLAGS@ @GTKMM_CFLAGS@ @GTKHTML_CFLAGS@
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ bool main_window::actions(int key)
|
|||||||
|
|
||||||
bool main_window::on_my_key_press_event(GdkEventKey *Key)
|
bool main_window::on_my_key_press_event(GdkEventKey *Key)
|
||||||
{
|
{
|
||||||
if (Key->keyval == gdk_keyval_from_name("Control_L"))
|
if (Key->keyval == gdk_keyval_from_name("Control_R"))
|
||||||
{
|
{
|
||||||
ctrl_state = 1;
|
ctrl_state = 1;
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ bool main_window::on_my_key_press_event(GdkEventKey *Key)
|
|||||||
|
|
||||||
bool main_window::on_my_key_release_event(GdkEventKey *Key)
|
bool main_window::on_my_key_release_event(GdkEventKey *Key)
|
||||||
{
|
{
|
||||||
if (Key->keyval == gdk_keyval_from_name("Control_L"))
|
if (Key->keyval == gdk_keyval_from_name("Control_R"))
|
||||||
{
|
{
|
||||||
ctrl_state = 0;
|
ctrl_state = 0;
|
||||||
}
|
}
|
||||||
|
46
src/message_dialog.cc
Normal file
46
src/message_dialog.cc
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "message_dialog.hh"
|
||||||
|
#include "vido.hh"
|
||||||
|
#include <gtkmm.h>
|
||||||
|
|
||||||
|
message_dialog::message_dialog(main_window* parent, std::string title, std::string txt)
|
||||||
|
{
|
||||||
|
Gtk::Dialog dialog(title, parent, true);
|
||||||
|
|
||||||
|
Gtk::Label label(txt);
|
||||||
|
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) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
35
src/message_dialog.hh
Normal file
35
src/message_dialog.hh
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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. *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef MESSAGE_DIALOG_HH
|
||||||
|
#define MESSAGE_DIALOG_HH
|
||||||
|
#include <gtkmm/dialog.h>
|
||||||
|
|
||||||
|
class main_window;
|
||||||
|
|
||||||
|
class message_dialog : public Gtk::Dialog{
|
||||||
|
|
||||||
|
public:
|
||||||
|
message_dialog(main_window* parent, std::string, std::string);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MESSAGE_DIALOG_HH
|
32
src/vido.cc
32
src/vido.cc
@ -26,6 +26,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "message_dialog.hh"
|
||||||
#include "vido.hh"
|
#include "vido.hh"
|
||||||
#include "main_window.hh"
|
#include "main_window.hh"
|
||||||
#include "search_dialog.hh"
|
#include "search_dialog.hh"
|
||||||
@ -41,6 +42,7 @@ extern "C" {
|
|||||||
std::string content;
|
std::string content;
|
||||||
std::string fileName;
|
std::string fileName;
|
||||||
|
|
||||||
|
main_window *window;
|
||||||
Gtk::Widget *html;
|
Gtk::Widget *html;
|
||||||
GtkWidget *html_wg;
|
GtkWidget *html_wg;
|
||||||
|
|
||||||
@ -60,6 +62,11 @@ const zim::File& get_file()
|
|||||||
return zimFile;
|
return zimFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void show_message(std::string title, std::string txt)
|
||||||
|
{
|
||||||
|
message_dialog(window, title, txt);
|
||||||
|
}
|
||||||
|
|
||||||
// // copy article html from while loop into global variable
|
// // copy article html from while loop into global variable
|
||||||
void set_article(const std::string& txt)
|
void set_article(const std::string& txt)
|
||||||
{
|
{
|
||||||
@ -76,24 +83,24 @@ void show_random()
|
|||||||
zim::File m = get_file();
|
zim::File m = get_file();
|
||||||
|
|
||||||
static unsigned int seed = static_cast<unsigned int>(time(0));
|
static unsigned int seed = static_cast<unsigned int>(time(0));
|
||||||
|
zim::size_type idx = static_cast<zim::size_type>(static_cast<double>(m.getCountArticles()) * rand_r(&seed) / RAND_MAX);
|
||||||
zim::Article article;
|
zim::Article article;
|
||||||
|
|
||||||
|
article = m.getArticle(idx);
|
||||||
|
|
||||||
|
//loop in case article is redirect
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
log_debug("random running loop");
|
article = article.getRedirectArticle();
|
||||||
zim::size_type idx = static_cast<zim::size_type>(static_cast<double>(m.getCountArticles()) * rand_r(&seed) / RAND_MAX);
|
}while(article.isRedirect());
|
||||||
|
|
||||||
log_debug("random index " << idx << " number of articles: " << m.getCountArticles());
|
std::string res = article.getPage();
|
||||||
|
|
||||||
article = m.getArticle(idx);
|
|
||||||
|
|
||||||
} while(article.isRedirect());
|
|
||||||
|
|
||||||
content = article.getPage();
|
content = article.getPage();
|
||||||
log_debug("article size=" << content.size());
|
log_debug("article size=" << content.size());
|
||||||
|
|
||||||
gtk_html_flush(GTK_HTML(html_wg));
|
gtk_html_flush(GTK_HTML(html_wg));
|
||||||
gtk_html_load_from_string(GTK_HTML(html_wg), content.c_str(), -1);
|
gtk_html_load_from_string(GTK_HTML(html_wg), res.c_str(), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // display search dialog
|
// // display search dialog
|
||||||
@ -164,6 +171,7 @@ void set_html(const gchar *url)
|
|||||||
|
|
||||||
// // load new data into gtkhtml widget
|
// // load new data into gtkhtml widget
|
||||||
gtk_html_load_from_string(GTK_HTML(html_wg), content.c_str(), -1);
|
gtk_html_load_from_string(GTK_HTML(html_wg), content.c_str(), -1);
|
||||||
|
// window.resize(220, 140);
|
||||||
log_debug("term=" << term << " url=" << url);
|
log_debug("term=" << term << " url=" << url);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -190,6 +198,7 @@ void set_search(const gchar *url)
|
|||||||
search.search(result, term);
|
search.search(result, term);
|
||||||
if(result.size() == 0)
|
if(result.size() == 0)
|
||||||
{
|
{
|
||||||
|
show_message("Error", "The article you requested (" + term + ") was not found.");
|
||||||
}
|
}
|
||||||
else if (result.size() == 1)
|
else if (result.size() == 1)
|
||||||
{
|
{
|
||||||
@ -214,6 +223,7 @@ void set_search(const gchar *url)
|
|||||||
|
|
||||||
gtk_html_flush(GTK_HTML(html_wg));
|
gtk_html_flush(GTK_HTML(html_wg));
|
||||||
gtk_html_load_from_string(GTK_HTML(html_wg), res.c_str(), -1);
|
gtk_html_load_from_string(GTK_HTML(html_wg), res.c_str(), -1);
|
||||||
|
// window.resize(220, 140);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +238,7 @@ bool on_link_clicked(GtkHTML *html, const gchar *url)
|
|||||||
{
|
{
|
||||||
|
|
||||||
set_html(url);
|
set_html(url);
|
||||||
// set_berlin(url);
|
// window.resize(220, 140);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +261,7 @@ int main(int argc, char **argv)
|
|||||||
main_window window;
|
main_window window;
|
||||||
window.set_title("Vido");
|
window.set_title("Vido");
|
||||||
// window.set_border_width(0);
|
// window.set_border_width(0);
|
||||||
window.set_default_size(320, 240);
|
window.set_default_size(220, 240);
|
||||||
// window.set_resizable(0);
|
// window.set_resizable(0);
|
||||||
|
|
||||||
html_wg = gtk_html_new();
|
html_wg = gtk_html_new();
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#ifndef VIDO_HH
|
#ifndef VIDO_HH
|
||||||
#define VIDO_HH
|
#define VIDO_HH
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user