Date:2010-01-18 13:17:26 (10 years 6 months ago)
Author:Mirko Lindner
Commit:f6d6448cfb6aadf808524d49d5f72ca7b26ad531
Message:make vido work again :)

Signed-off-by: Mirko Lindner <mirko@sharism.cc>
Files: src/Makefile.am (1 diff)
src/main_window.cc (2 diffs)
src/message_dialog.cc (1 diff)
src/message_dialog.hh (1 diff)
src/vido.cc (9 diffs)
src/vido.hh (1 diff)

Change Details

src/Makefile.am
11bin_PROGRAMS = vido
22
3vido_SOURCES = main_window.cc search_dialog.cc vido.cc
3vido_SOURCES = main_window.cc search_dialog.cc message_dialog.cc vido.cc
44
5noinst_HEADERS = main_window.hh search_dialog.hh
5noinst_HEADERS = main_window.hh search_dialog.hh message_dialog.hh
66
77AM_CXXFLAGS = @CXXFLAGS@ @GTKMM_CFLAGS@ @GTKHTML_CFLAGS@
88
src/main_window.cc
6464
6565bool main_window::on_my_key_press_event(GdkEventKey *Key)
6666{
67    if (Key->keyval == gdk_keyval_from_name("Control_L"))
67    if (Key->keyval == gdk_keyval_from_name("Control_R"))
6868    {
6969        ctrl_state = 1;
7070    }
...... 
8282
8383bool main_window::on_my_key_release_event(GdkEventKey *Key)
8484{
85    if (Key->keyval == gdk_keyval_from_name("Control_L"))
85    if (Key->keyval == gdk_keyval_from_name("Control_R"))
8686    {
8787        ctrl_state = 0;
8888    }
src/message_dialog.cc
1/***************************************************************************
2 * Copyright (C) 2009 by Mirko Lindner *
3 * mirko@qi-hardware.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21#include "config.h"
22#include "message_dialog.hh"
23#include "vido.hh"
24#include <gtkmm.h>
25
26message_dialog::message_dialog(main_window* parent, std::string title, std::string txt)
27{
28    Gtk::Dialog dialog(title, parent, true);
29
30    Gtk::Label label(txt);
31    dialog.get_vbox()->pack_start(label, true, true);
32// Gtk::Entry entry;
33// entry.set_text("");
34// dialog.get_vbox()->pack_start(entry, true, true);
35
36// dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
37    dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
38    dialog.show_all();
39    int result = dialog.run();
40    if (result == Gtk::RESPONSE_OK) {
41
42    } else {
43
44    }
45
46}
src/message_dialog.hh
1/***************************************************************************
2 * Copyright (C) 2009 by Mirko Lindner *
3 * mirko@qi-hardware.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21
22#ifndef MESSAGE_DIALOG_HH
23#define MESSAGE_DIALOG_HH
24#include <gtkmm/dialog.h>
25
26class main_window;
27
28class message_dialog : public Gtk::Dialog{
29
30    public:
31      message_dialog(main_window* parent, std::string, std::string);
32
33};
34
35#endif // MESSAGE_DIALOG_HH
src/vido.cc
2626#include <string>
2727
2828#include "config.h"
29#include "message_dialog.hh"
2930#include "vido.hh"
3031#include "main_window.hh"
3132#include "search_dialog.hh"
...... 
4142std::string content;
4243std::string fileName;
4344
45main_window *window;
4446Gtk::Widget *html;
4547GtkWidget *html_wg;
4648
...... 
6062  return zimFile;
6163}
6264
65void show_message(std::string title, std::string txt)
66{
67    message_dialog(window, title, txt);
68}
69
6370// // copy article html from while loop into global variable
6471void set_article(const std::string& txt)
6572{
...... 
7683    zim::File m = get_file();
7784
7885    static unsigned int seed = static_cast<unsigned int>(time(0));
79
86    zim::size_type idx = static_cast<zim::size_type>(static_cast<double>(m.getCountArticles()) * rand_r(&seed) / RAND_MAX);
8087    zim::Article article;
81    do
88
89    article = m.getArticle(idx);
90
91    //loop in case article is redirect
92    do
8293    {
83        log_debug("random running loop");
84        zim::size_type idx = static_cast<zim::size_type>(static_cast<double>(m.getCountArticles()) * rand_r(&seed) / RAND_MAX);
85
86        log_debug("random index " << idx << " number of articles: " << m.getCountArticles());
87
88        article = m.getArticle(idx);
89
90    } while(article.isRedirect());
94        article = article.getRedirectArticle();
95    }while(article.isRedirect());
96
97    std::string res = article.getPage();
9198
9299    content = article.getPage();
93100    log_debug("article size=" << content.size());
94101
95102    gtk_html_flush(GTK_HTML(html_wg));
96    gtk_html_load_from_string(GTK_HTML(html_wg), content.c_str(), -1);
103    gtk_html_load_from_string(GTK_HTML(html_wg), res.c_str(), -1);
97104}
98105
99106// // display search dialog
...... 
164171
165172// // load new data into gtkhtml widget
166173            gtk_html_load_from_string(GTK_HTML(html_wg), content.c_str(), -1);
174// window.resize(220, 140);
167175            log_debug("term=" << term << " url=" << url);
168176        }
169177        else
...... 
190198    search.search(result, term);
191199    if(result.size() == 0)
192200    {
201        show_message("Error", "The article you requested (" + term + ") was not found.");
193202    }
194203    else if (result.size() == 1)
195204    {
...... 
214223
215224        gtk_html_flush(GTK_HTML(html_wg));
216225        gtk_html_load_from_string(GTK_HTML(html_wg), res.c_str(), -1);
226// window.resize(220, 140);
217227
218228    }
219229
...... 
228238{
229239
230240    set_html(url);
231// set_berlin(url);
241// window.resize(220, 140);
232242    return true;
233243}
234244
...... 
251261      main_window window;
252262      window.set_title("Vido");
253263  // window.set_border_width(0);
254      window.set_default_size(320, 240);
264      window.set_default_size(220, 240);
255265  // window.set_resizable(0);
256266
257267      html_wg = gtk_html_new();
src/vido.hh
1919
2020#ifndef VIDO_HH
2121#define VIDO_HH
22#include <string>
2223
2324#include <gtkmm.h>
2425

Archive Download the corresponding diff file

Branches:
development
master



interactive