Wonderfull top bar
parent
b7d7fc115d
commit
513b2a9760
23
src/about.cc
23
src/about.cc
|
@ -1,17 +1,18 @@
|
|||
#include "about.h"
|
||||
|
||||
About::About() {
|
||||
set_name("Browser");
|
||||
set_version("0.1");
|
||||
std::vector<Glib::ustring> devs;
|
||||
devs.push_back("Melroy van den Berg <melroy@melroy.org>");
|
||||
icon.set_from_icon_name("emblem-web", Gtk::IconSize(Gtk::ICON_SIZE_DIALOG));
|
||||
|
||||
set_name("Browser");
|
||||
set_version("0.1.0");
|
||||
set_comments("The fastest decentralized browser on planet Earth.");
|
||||
set_icon(icon.get_pixbuf());
|
||||
set_website("https://melroy.org/");
|
||||
set_copyright("Copyright © 2020-2021 Melroy van den Berg");
|
||||
|
||||
std::vector<Glib::ustring> devs;
|
||||
devs.push_back("Melroy van den Berg");
|
||||
set_authors(devs);
|
||||
set_artists(devs);
|
||||
|
||||
set_license_type(Gtk::License::LICENSE_MIT_X11);
|
||||
|
||||
show_all_children();
|
||||
|
@ -20,3 +21,13 @@ About::About() {
|
|||
About::~About()
|
||||
{
|
||||
}
|
||||
|
||||
void About::show_about()
|
||||
{
|
||||
run();
|
||||
}
|
||||
|
||||
void About::hide_about(__attribute__((unused)) int response)
|
||||
{
|
||||
hide();
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
#define ABOUT_H
|
||||
|
||||
#include <gtkmm/aboutdialog.h>
|
||||
#include <gtkmm/image.h>
|
||||
|
||||
/**
|
||||
* \class About
|
||||
|
@ -10,9 +11,12 @@
|
|||
class About: public Gtk::AboutDialog
|
||||
{
|
||||
public:
|
||||
About();
|
||||
virtual ~About();
|
||||
About();
|
||||
virtual ~About();
|
||||
|
||||
void show_about();
|
||||
void hide_about(int response);
|
||||
protected:
|
||||
Gtk::Image icon; /*!< The logo of the app */
|
||||
};
|
||||
#endif
|
|
@ -1,8 +1,12 @@
|
|||
#include "ipfs.h"
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
|
||||
int IPFS::startIPFSDaemon()
|
||||
{
|
||||
// Be sure to kill any running daemons
|
||||
std::system("killall -q ipfs");
|
||||
|
||||
// Start IPFS daemon
|
||||
constexpr char *proc[] = { "../../go-ipfs/ipfs", "daemon", "--init", "--migrate", 0};
|
||||
return execv(proc[0], proc);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "mainwindow.h"
|
||||
|
||||
#include <gtkmm/menuitem.h>
|
||||
#include <gtkmm/image.h>
|
||||
|
||||
#ifdef LEGACY_CXX
|
||||
#include <experimental/filesystem>
|
||||
namespace n_fs = ::std::experimental::filesystem;
|
||||
|
@ -9,7 +11,9 @@ namespace n_fs = ::std::experimental::filesystem;
|
|||
namespace n_fs = ::std::filesystem;
|
||||
#endif
|
||||
|
||||
MainWindow::MainWindow() : m_vbox(Gtk::ORIENTATION_VERTICAL, 0)
|
||||
MainWindow::MainWindow()
|
||||
: m_vbox(Gtk::ORIENTATION_VERTICAL, 0),
|
||||
m_hbox_bar(Gtk::ORIENTATION_HORIZONTAL, 0)
|
||||
{
|
||||
set_title("Browser");
|
||||
set_default_size(1000, 800);
|
||||
|
@ -17,12 +21,43 @@ MainWindow::MainWindow() : m_vbox(Gtk::ORIENTATION_VERTICAL, 0)
|
|||
|
||||
// Connect signals
|
||||
m_menu.quit.connect(sigc::mem_fun(this, &MainWindow::hide)); /*!< hide main window and therefor closes the app */
|
||||
m_menu.reload.connect(sigc::mem_fun(this, &MainWindow::demo)); /*!< reload the page again */
|
||||
m_menu.about.connect(sigc::mem_fun(this, &MainWindow::show_about));
|
||||
m_about.signal_response().connect(sigc::mem_fun(this, &MainWindow::hide_about));
|
||||
m_menu.reload.connect(sigc::mem_fun(this, &MainWindow::demo)); /*!< Menu item for reloading the page */
|
||||
m_menu.about.connect(sigc::mem_fun(m_about, &About::show_about)); /*!< Display about dialog */
|
||||
m_about.signal_response().connect(sigc::mem_fun(m_about, &About::hide_about)); /*!< Close about dialog */
|
||||
m_refreshButton.signal_clicked().connect(sigc::mem_fun(this, &MainWindow::demo)); /*!< Button for reloading the page */
|
||||
|
||||
m_vbox.pack_start(m_menu, false, false, 0);
|
||||
|
||||
// Horizontal bar
|
||||
auto styleBack = m_backButton.get_style_context();
|
||||
styleBack->add_class("circular");
|
||||
auto styleForward = m_forwardButton.get_style_context();
|
||||
styleForward->add_class("circular");
|
||||
auto styleRefresh = m_refreshButton.get_style_context();
|
||||
styleRefresh->add_class("circular");
|
||||
m_backButton.set_relief(Gtk::RELIEF_NONE);
|
||||
m_forwardButton.set_relief(Gtk::RELIEF_NONE);
|
||||
m_refreshButton.set_relief(Gtk::RELIEF_NONE);
|
||||
m_homeButton.set_relief(Gtk::RELIEF_NONE);
|
||||
|
||||
// Add icons to buttons
|
||||
backIcon.set_from_icon_name("go-previous", Gtk::IconSize(Gtk::ICON_SIZE_MENU));
|
||||
m_backButton.add(backIcon);
|
||||
forwardIcon.set_from_icon_name("go-next", Gtk::IconSize(Gtk::ICON_SIZE_MENU));
|
||||
m_forwardButton.add(forwardIcon);
|
||||
refreshIcon.set_from_icon_name("view-refresh", Gtk::IconSize(Gtk::ICON_SIZE_MENU));
|
||||
m_refreshButton.add(refreshIcon);
|
||||
homeIcon.set_from_icon_name("go-home", Gtk::IconSize(Gtk::ICON_SIZE_MENU));
|
||||
m_homeButton.add(homeIcon);
|
||||
|
||||
m_hbox_bar.pack_start(m_backButton, false, false , 0);
|
||||
m_hbox_bar.pack_start(m_forwardButton, false, false , 0);
|
||||
m_hbox_bar.pack_start(m_refreshButton, false, false , 0);
|
||||
m_hbox_bar.pack_start(m_homeButton, false, false , 0);
|
||||
m_hbox_bar.pack_start(m_inputField, true, true , 8);
|
||||
m_vbox.pack_start(m_hbox_bar, false, false, 6);
|
||||
|
||||
// Main browser rendering area
|
||||
m_scrolledWindow.add(m_renderArea);
|
||||
m_scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
||||
|
||||
|
@ -30,6 +65,8 @@ MainWindow::MainWindow() : m_vbox(Gtk::ORIENTATION_VERTICAL, 0)
|
|||
add(m_vbox);
|
||||
show_all_children();
|
||||
|
||||
// Grap focus to input field by default
|
||||
m_inputField.grab_focus();
|
||||
|
||||
demo();
|
||||
}
|
||||
|
@ -58,12 +95,4 @@ void MainWindow::demo()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::show_about()
|
||||
{
|
||||
m_about.run();
|
||||
}
|
||||
|
||||
void MainWindow::hide_about(int response)
|
||||
{
|
||||
m_about.hide();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/menubar.h>
|
||||
#include <gtkmm/scrolledwindow.h>
|
||||
#include <gtkmm/button.h>
|
||||
#include <gtkmm/entry.h>
|
||||
#include "render-area.h"
|
||||
#include "menu.h"
|
||||
#include "file.h"
|
||||
|
@ -25,6 +27,16 @@ protected:
|
|||
// Child widgets
|
||||
Menu m_menu;
|
||||
Gtk::Box m_vbox;
|
||||
Gtk::Box m_hbox_bar;
|
||||
Gtk::Button m_backButton;
|
||||
Gtk::Button m_forwardButton;
|
||||
Gtk::Button m_refreshButton;
|
||||
Gtk::Button m_homeButton;
|
||||
Gtk::Entry m_inputField;
|
||||
Gtk::Image backIcon;
|
||||
Gtk::Image forwardIcon;
|
||||
Gtk::Image refreshIcon;
|
||||
Gtk::Image homeIcon;
|
||||
Gtk::ScrolledWindow m_scrolledWindow;
|
||||
RenderArea m_renderArea;
|
||||
About m_about;
|
||||
|
|
Loading…
Reference in New Issue