mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-12 05:31:06 +00:00
draft action dependencies
This commit is contained in:
parent
45dc3b160a
commit
c940e5f7df
@ -9,7 +9,7 @@ Browser::Browser(
|
||||
//const std::shared_ptr<lib::Database> & db
|
||||
) {
|
||||
// Init window actions
|
||||
add_action(
|
||||
const auto ACTION__REFRESH = add_action(
|
||||
"refresh",
|
||||
[this]
|
||||
{
|
||||
@ -45,14 +45,12 @@ Browser::Browser(
|
||||
}
|
||||
);
|
||||
|
||||
add_action(
|
||||
const auto ACTION__MAIN_TAB_CLOSE = add_action(
|
||||
"main_tab_close",
|
||||
[this]
|
||||
{
|
||||
browserMain->tab_close();
|
||||
}
|
||||
)->set_enabled(
|
||||
false
|
||||
);
|
||||
|
||||
add_action(
|
||||
@ -96,24 +94,20 @@ Browser::Browser(
|
||||
false
|
||||
);
|
||||
|
||||
add_action(
|
||||
const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK = add_action(
|
||||
"main_tab_page_navigation_history_back",
|
||||
[this]
|
||||
{
|
||||
browserMain->tab_page_navigation_history_back();
|
||||
}
|
||||
)->set_enabled(
|
||||
false
|
||||
);
|
||||
|
||||
add_action(
|
||||
const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD = add_action(
|
||||
"main_tab_page_navigation_history_forward",
|
||||
[this]
|
||||
{
|
||||
browserMain->tab_page_navigation_history_forward();
|
||||
}
|
||||
)->set_enabled(
|
||||
false
|
||||
);
|
||||
|
||||
// Init widget
|
||||
@ -134,7 +128,12 @@ Browser::Browser(
|
||||
);
|
||||
|
||||
// Init main widget
|
||||
browserMain = Gtk::make_managed<browser::Main>();
|
||||
browserMain = Gtk::make_managed<browser::Main>(
|
||||
ACTION__REFRESH,
|
||||
ACTION__MAIN_TAB_CLOSE,
|
||||
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
|
||||
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD
|
||||
);
|
||||
|
||||
set_child(
|
||||
* browserMain
|
||||
|
@ -1,7 +1,9 @@
|
||||
#ifndef APP_BROWSER_HPP
|
||||
#define APP_BROWSER_HPP
|
||||
|
||||
#include <giomm/simpleaction.h>
|
||||
#include <glibmm/i18n.h>
|
||||
#include <glibmm/refptr.h>
|
||||
#include <gtkmm/applicationwindow.h>
|
||||
#include <gtkmm/object.h>
|
||||
|
||||
@ -20,9 +22,11 @@ namespace app
|
||||
|
||||
class Browser : public Gtk::ApplicationWindow
|
||||
{
|
||||
// Components
|
||||
app::browser::Header * browserHeader;
|
||||
app::browser::Main * browserMain;
|
||||
|
||||
// Defaults
|
||||
const int WIDTH = 640;
|
||||
const int HEIGHT = 480;
|
||||
|
||||
|
@ -3,8 +3,12 @@
|
||||
|
||||
using namespace app::browser;
|
||||
|
||||
Main::Main()
|
||||
{
|
||||
Main::Main(
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD
|
||||
) {
|
||||
// Init container
|
||||
set_orientation(
|
||||
Gtk::Orientation::VERTICAL
|
||||
@ -15,7 +19,12 @@ Main::Main()
|
||||
);
|
||||
|
||||
// Init tabs
|
||||
mainTab = Gtk::make_managed<main::Tab>();
|
||||
mainTab = Gtk::make_managed<main::Tab>(
|
||||
ACTION__REFRESH,
|
||||
ACTION__MAIN_TAB_CLOSE,
|
||||
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
|
||||
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD
|
||||
);
|
||||
|
||||
append(
|
||||
* mainTab
|
||||
|
@ -1,7 +1,9 @@
|
||||
#ifndef APP_BROWSER_MAIN_HPP
|
||||
#define APP_BROWSER_MAIN_HPP
|
||||
|
||||
#include <giomm/simpleaction.h>
|
||||
#include <glibmm/i18n.h>
|
||||
#include <glibmm/refptr.h>
|
||||
#include <glibmm/ustring.h>
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/object.h>
|
||||
@ -23,7 +25,12 @@ namespace app::browser
|
||||
|
||||
public:
|
||||
|
||||
Main();
|
||||
Main(
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD
|
||||
);
|
||||
|
||||
// Actions
|
||||
void refresh();
|
||||
|
@ -4,21 +4,29 @@
|
||||
|
||||
using namespace app::browser::main;
|
||||
|
||||
Tab::Tab()
|
||||
{
|
||||
Tab::Tab(
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD
|
||||
) {
|
||||
// Init actions
|
||||
action__refresh = ACTION__REFRESH;
|
||||
action__tab_close = ACTION__TAB_CLOSE;
|
||||
action__tab_page_navigation_history_back = ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK;
|
||||
action__tab_page_navigation_history_forward = ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD;
|
||||
|
||||
// Init widget
|
||||
set_scrollable(
|
||||
SCROLLABLE
|
||||
);
|
||||
|
||||
// Init events
|
||||
// Init event listeners
|
||||
signal_switch_page().connect(
|
||||
[this](Gtk::Widget*, guint)
|
||||
{
|
||||
// Refresh window elements, e.g. tab label to header bar
|
||||
activate_action(
|
||||
"win.refresh"
|
||||
);
|
||||
action__refresh->activate();
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -31,7 +39,9 @@ void Tab::refresh(
|
||||
PAGE_NUMBER
|
||||
);
|
||||
|
||||
get_tabLabel(PAGE_NUMBER)->set_label(
|
||||
get_tabLabel(
|
||||
PAGE_NUMBER
|
||||
)->set_label(
|
||||
tabPage->get_title()
|
||||
);
|
||||
}
|
||||
@ -45,11 +55,13 @@ void Tab::append(
|
||||
auto tabPage = new tab::Page(
|
||||
TITLE,
|
||||
SUBTITLE,
|
||||
REQUEST
|
||||
REQUEST,
|
||||
action__tab_page_navigation_history_back,
|
||||
action__tab_page_navigation_history_forward
|
||||
);
|
||||
|
||||
auto tabLabel = new tab::Label(
|
||||
TITLE
|
||||
action__tab_close
|
||||
);
|
||||
|
||||
int page_number = append_page(
|
||||
|
@ -1,7 +1,9 @@
|
||||
#ifndef APP_BROWSER_MAIN_TAB_HPP
|
||||
#define APP_BROWSER_MAIN_TAB_HPP
|
||||
|
||||
#include <giomm/simpleaction.h>
|
||||
#include <glibmm/i18n.h>
|
||||
#include <glibmm/refptr.h>
|
||||
#include <glibmm/ustring.h>
|
||||
#include <gtkmm/notebook.h>
|
||||
|
||||
@ -15,9 +17,13 @@ namespace app::browser::main
|
||||
|
||||
class Tab : public Gtk::Notebook
|
||||
{
|
||||
const bool REORDERABLE = true;
|
||||
const bool SCROLLABLE = true;
|
||||
// Actions
|
||||
Glib::RefPtr<Gio::SimpleAction> action__refresh,
|
||||
action__tab_close,
|
||||
action__tab_page_navigation_history_back,
|
||||
action__tab_page_navigation_history_forward;
|
||||
|
||||
// Components
|
||||
tab::Label * get_tabLabel(
|
||||
const int & PAGE_NUMBER
|
||||
);
|
||||
@ -26,9 +32,18 @@ namespace app::browser::main
|
||||
const int & PAGE_NUMBER
|
||||
);
|
||||
|
||||
// Defaults
|
||||
const bool REORDERABLE = true;
|
||||
const bool SCROLLABLE = true;
|
||||
|
||||
public:
|
||||
|
||||
Tab();
|
||||
Tab(
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD
|
||||
);
|
||||
|
||||
// Actions
|
||||
void refresh(
|
||||
|
@ -3,11 +3,10 @@
|
||||
using namespace app::browser::main::tab;
|
||||
|
||||
Label::Label(
|
||||
const Glib::ustring & TEXT
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE
|
||||
) {
|
||||
set_text(
|
||||
TEXT
|
||||
);
|
||||
// Init actions
|
||||
action__close = ACTION__CLOSE;
|
||||
|
||||
// Setup label controller
|
||||
auto GtkGestureClick = Gtk::GestureClick::create();
|
||||
@ -22,9 +21,7 @@ Label::Label(
|
||||
{
|
||||
if (n == 2) // double click
|
||||
{
|
||||
activate_action(
|
||||
"win.main_tab_close"
|
||||
);
|
||||
action__close->activate();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef APP_BROWSER_MAIN_TAB_LABEL_HPP
|
||||
#define APP_BROWSER_MAIN_TAB_LABEL_HPP
|
||||
|
||||
#include <giomm/simpleaction.h>
|
||||
#include <glibmm/i18n.h>
|
||||
#include <glibmm/refptr.h>
|
||||
#include <glibmm/ustring.h>
|
||||
@ -11,10 +12,12 @@ namespace app::browser::main::tab
|
||||
{
|
||||
class Label : public Gtk::Label
|
||||
{
|
||||
Glib::RefPtr<Gio::SimpleAction> action__close;
|
||||
|
||||
public:
|
||||
|
||||
Label(
|
||||
const Glib::ustring & TEXT
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE
|
||||
);
|
||||
};
|
||||
}
|
||||
|
@ -7,7 +7,9 @@ using namespace app::browser::main::tab;
|
||||
Page::Page(
|
||||
const Glib::ustring & TITLE,
|
||||
const Glib::ustring & SUBTITLE,
|
||||
const Glib::ustring & REQUEST
|
||||
const Glib::ustring & REQUEST,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_BACK,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_FORWARD
|
||||
) {
|
||||
// Init container
|
||||
set_orientation(
|
||||
@ -16,7 +18,9 @@ Page::Page(
|
||||
|
||||
// Init components
|
||||
pageNavigation = Gtk::make_managed<page::Navigation>(
|
||||
REQUEST
|
||||
REQUEST,
|
||||
ACTION__PAGE_NAVIGATION_HISTORY_BACK,
|
||||
ACTION__PAGE_NAVIGATION_HISTORY_FORWARD
|
||||
);
|
||||
|
||||
append(
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <giomm/asyncresult.h>
|
||||
#include <giomm/inputstream.h>
|
||||
#include <giomm/outputstream.h>
|
||||
#include <giomm/simpleaction.h>
|
||||
#include <giomm/socketclient.h>
|
||||
#include <giomm/socketconnection.h>
|
||||
#include <glibmm/i18n.h>
|
||||
@ -43,7 +44,9 @@ namespace app::browser::main::tab
|
||||
Page(
|
||||
const Glib::ustring & TITLE,
|
||||
const Glib::ustring & SUBTITLE,
|
||||
const Glib::ustring & REQUEST
|
||||
const Glib::ustring & REQUEST,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_BACK,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_FORWARD
|
||||
);
|
||||
|
||||
// Actions
|
||||
|
@ -8,7 +8,9 @@
|
||||
using namespace app::browser::main::tab::page;
|
||||
|
||||
Navigation::Navigation(
|
||||
const Glib::ustring & REQUEST
|
||||
const Glib::ustring & REQUEST,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_HISTORY_BACK,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_HISTORY_FORWARD
|
||||
) {
|
||||
// Init container
|
||||
set_orientation(
|
||||
@ -42,7 +44,10 @@ Navigation::Navigation(
|
||||
* navigationBase
|
||||
);
|
||||
|
||||
navigationHistory = Gtk::make_managed<navigation::History>();
|
||||
navigationHistory = Gtk::make_managed<navigation::History>(
|
||||
ACTION__NAVIGATION_HISTORY_BACK,
|
||||
ACTION__NAVIGATION_HISTORY_FORWARD
|
||||
);
|
||||
|
||||
append(
|
||||
* navigationHistory
|
||||
|
@ -1,7 +1,9 @@
|
||||
#ifndef APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_HPP
|
||||
#define APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_HPP
|
||||
|
||||
#include <giomm/simpleaction.h>
|
||||
#include <giomm/simpleactiongroup.h>
|
||||
#include <glibmm/refptr.h>
|
||||
#include <glibmm/ustring.h>
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/object.h>
|
||||
@ -33,7 +35,9 @@ namespace app::browser::main::tab::page
|
||||
public:
|
||||
|
||||
Navigation(
|
||||
const Glib::ustring & REQUEST
|
||||
const Glib::ustring & REQUEST,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_HISTORY_BACK,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_HISTORY_FORWARD
|
||||
);
|
||||
|
||||
// Actions
|
||||
|
@ -4,19 +4,25 @@
|
||||
|
||||
using namespace app::browser::main::tab::page::navigation;
|
||||
|
||||
History::History()
|
||||
{
|
||||
History::History(
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD
|
||||
) {
|
||||
add_css_class(
|
||||
"linked" // merge children elements
|
||||
);
|
||||
|
||||
historyBack = Gtk::make_managed<history::Back>();
|
||||
historyBack = Gtk::make_managed<history::Back>(
|
||||
ACTION__HISTORY_BACK
|
||||
);
|
||||
|
||||
append(
|
||||
* historyBack
|
||||
);
|
||||
|
||||
historyForward = Gtk::make_managed<history::Forward>();
|
||||
historyForward = Gtk::make_managed<history::Forward>(
|
||||
ACTION__HISTORY_FORWARD
|
||||
);
|
||||
|
||||
append(
|
||||
* historyForward
|
||||
|
@ -2,7 +2,9 @@
|
||||
#define APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_HISTORY_HPP
|
||||
|
||||
#include <ctime>
|
||||
#include <giomm/simpleaction.h>
|
||||
#include <glibmm/i18n.h>
|
||||
#include <glibmm/refptr.h>
|
||||
#include <glibmm/ustring.h>
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/object.h>
|
||||
@ -37,7 +39,10 @@ namespace app::browser::main::tab::page::navigation
|
||||
// Define navigation history storage
|
||||
std::vector<Memory> memory;
|
||||
|
||||
History();
|
||||
History(
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD
|
||||
);
|
||||
|
||||
// Actions
|
||||
void add(
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
using namespace app::browser::main::tab::page::navigation::history;
|
||||
|
||||
Back::Back()
|
||||
{
|
||||
Back::Back(
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__BACK
|
||||
) {
|
||||
set_action_name(
|
||||
"win.main_tab_page_navigation_history_back"
|
||||
"win.main_tab_page_navigation_history_back" // @TODO
|
||||
);
|
||||
|
||||
set_icon_name(
|
||||
|
@ -1,7 +1,9 @@
|
||||
#ifndef APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK_HPP
|
||||
#define APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK_HPP
|
||||
|
||||
#include <giomm/simpleaction.h>
|
||||
#include <glibmm/i18n.h>
|
||||
#include <glibmm/refptr.h>
|
||||
#include <gtkmm/button.h>
|
||||
|
||||
namespace app::browser::main::tab::page::navigation::history
|
||||
@ -10,7 +12,9 @@ namespace app::browser::main::tab::page::navigation::history
|
||||
{
|
||||
public:
|
||||
|
||||
Back();
|
||||
Back(
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__BACK
|
||||
);
|
||||
|
||||
void refresh(
|
||||
const bool & ENABLED
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
using namespace app::browser::main::tab::page::navigation::history;
|
||||
|
||||
Forward::Forward()
|
||||
{
|
||||
Forward::Forward(
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__FORWARD
|
||||
) {
|
||||
set_action_name(
|
||||
"win.main_tab_page_navigation_history_forward"
|
||||
"win.main_tab_page_navigation_history_forward" // @TODO
|
||||
);
|
||||
|
||||
set_icon_name(
|
||||
|
@ -1,7 +1,9 @@
|
||||
#ifndef APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD_HPP
|
||||
#define APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD_HPP
|
||||
|
||||
#include <giomm/simpleaction.h>
|
||||
#include <glibmm/i18n.h>
|
||||
#include <glibmm/refptr.h>
|
||||
#include <gtkmm/button.h>
|
||||
|
||||
namespace app::browser::main::tab::page::navigation::history
|
||||
@ -10,7 +12,9 @@ namespace app::browser::main::tab::page::navigation::history
|
||||
{
|
||||
public:
|
||||
|
||||
Forward();
|
||||
Forward(
|
||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__FORWARD
|
||||
);
|
||||
|
||||
void refresh(
|
||||
const bool & ENABLED
|
||||
|
Loading…
x
Reference in New Issue
Block a user