LibreWeb-Browser/src/mainwindow.h

83 lines
2.1 KiB
C
Raw Normal View History

2020-11-12 14:27:47 -08:00
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
2020-11-28 14:47:34 -08:00
#include <gtkmm/window.h>
2020-11-30 15:43:52 -08:00
#include <gtkmm/box.h>
#include <gtkmm/menubar.h>
2020-11-28 14:47:34 -08:00
#include <gtkmm/scrolledwindow.h>
2020-12-08 19:44:26 -08:00
#include <gtkmm/button.h>
#include <gtkmm/entry.h>
2021-02-17 12:38:16 -08:00
#include <gtkmm/searchbar.h>
#include <gtkmm/searchentry.h>
2020-12-14 14:57:36 -08:00
#include <thread>
2020-11-30 15:43:52 -08:00
#include "menu.h"
2020-12-04 17:51:40 -08:00
#include "file.h"
2020-12-07 16:13:21 -08:00
#include "about.h"
2020-12-11 21:02:17 -08:00
#include "source-code-dialog.h"
2021-02-11 14:04:50 -08:00
#include "draw.h"
2020-11-12 14:27:47 -08:00
2021-02-17 09:05:12 -08:00
/**
* \class MainWindow
* \brief Main Application Window
*/
2020-11-28 14:47:34 -08:00
class MainWindow : public Gtk::Window
2020-11-12 14:27:47 -08:00
{
public:
2021-02-12 12:46:41 -08:00
MainWindow();
void doRequest(const std::string &path= std::string(), bool setAddressBar = false, bool isHistoryRequest = false);
2020-11-14 14:13:00 -08:00
2020-11-28 14:47:34 -08:00
protected:
2021-02-17 12:11:07 -08:00
// Signal handlers
2021-02-18 15:44:21 -08:00
void new_doc();
2021-02-12 12:46:41 -08:00
void go_home();
2021-02-15 10:03:07 -08:00
void address_bar_activate();
2021-02-17 12:38:16 -08:00
void do_search();
void show_search();
void back();
void forward();
2021-02-12 12:46:41 -08:00
void refresh();
void on_button_clicked(Glib::ustring data);
void show_about();
void hide_about(int response);
void show_source_code_dialog();
2021-02-17 12:11:07 -08:00
Glib::RefPtr<Gtk::AccelGroup> accelGroup; /*!< Accelerator group, used for keyboard shortcut bindings */
2021-02-12 12:46:41 -08:00
// Child widgets
Menu m_menu;
2021-02-15 11:19:25 -08:00
Draw m_draw;
SourceCodeDialog m_sourceCodeDialog;
About m_about;
2021-02-17 12:38:16 -08:00
Gtk::SearchBar m_search;
Gtk::SearchEntry m_searchEntry;
2021-02-12 12:46:41 -08:00
Gtk::Box m_vbox;
2021-02-17 12:38:16 -08:00
Gtk::Box m_hboxBar;
Gtk::Box m_hboxBottom;
2021-02-12 12:46:41 -08:00
Gtk::Button m_backButton;
Gtk::Button m_forwardButton;
Gtk::Button m_refreshButton;
Gtk::Button m_homeButton;
2021-02-15 10:03:07 -08:00
Gtk::Entry m_addressBar;
2021-02-12 12:46:41 -08:00
Gtk::Image backIcon;
Gtk::Image forwardIcon;
Gtk::Image refreshIcon;
Gtk::Image homeIcon;
Gtk::ScrolledWindow m_scrolledWindow;
2021-02-17 12:57:52 -08:00
Gtk::Button m_exitBottomButton;
2020-11-12 14:27:47 -08:00
private:
2021-02-12 12:46:41 -08:00
File m_file;
std::thread *m_requestThread;
std::string requestPath;
std::string finalRequestPath;
std::string currentContent;
std::size_t currentHistoryIndex;
2021-02-15 12:32:48 -08:00
std::vector<std::string> history;
void postDoRequest(const std::string &path, bool setAddressBar, bool isHistoryRequest);
2021-02-15 10:03:07 -08:00
void processRequest(const std::string &path);
2021-02-12 12:46:41 -08:00
void fetchFromIPFS();
void openFromDisk();
2020-11-12 14:27:47 -08:00
};
2020-11-14 14:13:00 -08:00
#endif