LibreWeb-Browser/src/mainwindow.h

180 lines
5.2 KiB
C
Raw Normal View History

2020-11-12 14:27:47 -08:00
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
2021-03-27 16:50:04 -07:00
#include "menu.h"
#include "about.h"
#include "source-code-dialog.h"
#include "draw.h"
#include "ipfs.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>
2021-03-11 15:13:29 -08:00
#include <gtkmm/togglebutton.h>
2021-02-19 13:58:55 -08:00
#include <gtkmm/comboboxtext.h>
2021-03-27 16:50:04 -07:00
#include <gtkmm/popover.h>
2021-03-29 13:03:14 -07:00
#include <gtkmm/filechooserdialog.h>
2020-12-08 19:44:26 -08:00
#include <gtkmm/entry.h>
2021-02-17 12:38:16 -08:00
#include <gtkmm/searchbar.h>
#include <gtkmm/searchentry.h>
2021-02-24 13:56:56 -08:00
#include <gtkmm/paned.h>
#include <giomm/settings.h>
2020-12-14 14:57:36 -08:00
#include <thread>
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();
2021-03-03 10:03:55 -08:00
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
bool delete_window(GdkEventAny* any_event);
2021-03-27 16:50:04 -07:00
bool update_connection_status();
2021-03-03 10:03:55 -08:00
void cut();
void copy();
void paste();
void del();
void selectAll();
2021-02-18 15:44:21 -08:00
void new_doc();
void open();
2021-03-29 13:03:14 -07:00
void on_open_dialog_response(int response_id, Gtk::FileChooserDialog* dialog);
void save();
void save_as();
2021-03-29 13:03:14 -07:00
void on_save_as_dialog_response(int response_id, Gtk::FileChooserDialog* dialog);
void publish();
2021-02-12 12:46:41 -08:00
void go_home();
2021-03-27 16:50:04 -07:00
void show_status();
2021-02-15 10:03:07 -08:00
void address_bar_activate();
2021-03-12 13:44:48 -08:00
void on_search();
void on_replace();
void show_search(bool replace);
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);
2021-02-24 14:39:32 -08:00
void editor_changed_text();
2021-02-12 12:46:41 -08:00
void show_source_code_dialog();
2021-02-19 13:58:55 -08:00
void get_heading();
2021-02-12 12:46:41 -08:00
Glib::RefPtr<Gtk::AccelGroup> m_accelGroup; /*!< Accelerator group, used for keyboard shortcut bindings */
Glib::RefPtr<Gio::Settings> m_settings; /*!< Settings to store our preferences, even during restarts */
2021-02-17 12:11:07 -08:00
2021-02-12 12:46:41 -08:00
// Child widgets
Menu m_menu;
2021-02-24 13:56:56 -08:00
Draw m_draw_main;
Draw m_draw_secondary;
2021-02-15 11:19:25 -08:00
SourceCodeDialog m_sourceCodeDialog;
About m_about;
2021-02-24 13:56:56 -08:00
Gtk::HPaned m_paned;
2021-02-17 12:38:16 -08:00
Gtk::SearchBar m_search;
2021-03-12 13:44:48 -08:00
Gtk::SearchBar m_searchReplace;
2021-02-17 12:38:16 -08:00
Gtk::SearchEntry m_searchEntry;
2021-03-12 13:44:48 -08:00
Gtk::Entry m_searchReplaceEntry;
2021-02-12 12:46:41 -08:00
Gtk::Box m_vbox;
Gtk::Box m_hboxBrowserToolbar;
Gtk::Box m_hboxStandardEditorToolbar;
Gtk::Box m_hboxFormattingEditorToolbar;
2021-02-17 12:38:16 -08:00
Gtk::Box m_hboxBottom;
2021-02-19 10:38:05 -08:00
Gtk::Entry m_addressBar;
2021-03-11 15:13:29 -08:00
Gtk::ToggleButton m_searchMatchCase;
2021-02-12 12:46:41 -08:00
Gtk::Button m_backButton;
Gtk::Button m_forwardButton;
Gtk::Button m_refreshButton;
Gtk::Button m_homeButton;
Gtk::Button m_statusButton;
Gtk::Button m_openButton;
Gtk::Button m_saveButton;
2021-03-09 13:38:23 -08:00
Gtk::Button m_publishButton;
Gtk::Button m_cutButton;
Gtk::Button m_copyButton;
Gtk::Button m_pasteButton;
Gtk::Button m_undoButton;
Gtk::Button m_redoButton;
2021-02-19 13:58:55 -08:00
Gtk::ComboBoxText m_headingsComboBox;
2021-02-19 10:38:05 -08:00
Gtk::Button m_boldButton;
Gtk::Button m_italicButton;
Gtk::Button m_strikethroughButton;
Gtk::Button m_superButton;
Gtk::Button m_subButton;
Gtk::Button m_linkButton;
Gtk::Button m_imageButton;
Gtk::Button m_quoteButton;
Gtk::Button m_codeButton;
2021-02-19 10:38:05 -08:00
Gtk::Button m_bulletListButton;
Gtk::Button m_numberedListButton;
Gtk::Button m_highlightButton;
2021-02-23 15:18:10 -08:00
Gtk::Image m_backIcon;
Gtk::Image m_forwardIcon;
Gtk::Image m_refreshIcon;
Gtk::Image m_homeIcon;
2021-03-27 11:36:00 -07:00
Gtk::Image m_statusIcon;
Glib::RefPtr<Gdk::Pixbuf> m_statusOfflineIcon;
Glib::RefPtr<Gdk::Pixbuf> m_statusOnlineIcon;
Gtk::Image m_openIcon;
Gtk::Image m_saveIcon;
2021-03-09 13:38:23 -08:00
Gtk::Image m_publishIcon;
Gtk::Image m_cutIcon;
Gtk::Image m_copyIcon;
Gtk::Image m_pasteIcon;
Gtk::Image m_undoIcon;
Gtk::Image m_redoIcon;
2021-02-23 15:18:10 -08:00
Gtk::Image m_boldIcon;
Gtk::Image m_italicIcon;
Gtk::Image m_strikethroughIcon;
Gtk::Image m_superIcon;
Gtk::Image m_subIcon;
Gtk::Image m_linkIcon;
Gtk::Image m_imageIcon;
Gtk::Image m_quoteIcon;
Gtk::Image m_codeIcon;
2021-02-23 15:18:10 -08:00
Gtk::Image m_bulletListIcon;
Gtk::Image m_numberedListIcon;
Gtk::Image m_hightlightIcon;
2021-03-27 16:50:04 -07:00
Gtk::Popover m_statusPopover;
Gtk::Label m_statusLabel;
2021-02-24 13:56:56 -08:00
Gtk::ScrolledWindow m_scrolledWindowMain;
Gtk::ScrolledWindow m_scrolledWindowSecondary;
2021-02-17 12:57:52 -08:00
Gtk::Button m_exitBottomButton;
Gtk::SeparatorMenuItem m_separator1;
Gtk::SeparatorMenuItem m_separator2;
Gtk::SeparatorMenuItem m_separator3;
2021-03-09 13:40:58 -08:00
Gtk::SeparatorMenuItem m_separator4;
2020-11-12 14:27:47 -08:00
private:
2021-02-19 10:38:05 -08:00
std::string m_appName;
std::string m_iconTheme;
bool m_useCurrentGTKIconTheme;
int m_iconSize;
2021-02-12 12:46:41 -08:00
std::thread *m_requestThread;
std::string requestPath;
std::string finalRequestPath;
std::string currentContent;
2021-03-29 13:03:14 -07:00
std::string currentFileSavedPath;
std::size_t currentHistoryIndex;
2021-02-15 12:32:48 -08:00
std::vector<std::string> history;
2021-02-24 14:39:32 -08:00
sigc::connection textChangedSignalHandler;
2021-03-27 11:36:00 -07:00
sigc::connection statusTimerHandler;
IPFS ipfs;
bool isInstalled();
2021-02-24 13:56:56 -08:00
void enableEdit();
void disableEdit();
2021-03-29 13:03:14 -07:00
bool isEditorEnabled();
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();
std::string getIconImageFromTheme(const std::string &iconName, const std::string &typeofIcon);
2020-11-12 14:27:47 -08:00
};
2020-11-14 14:13:00 -08:00
2021-02-19 10:38:05 -08:00
#endif