Browse Source

add page title support, make arguments linked const

CPP-GTK4
yggverse 3 months ago
parent
commit
c75744f777
  1. 4
      src/app/browser/main.cpp
  2. 1
      src/app/browser/main.hpp
  3. 14
      src/app/browser/main/tab.cpp
  4. 5
      src/app/browser/main/tab.hpp
  5. 17
      src/app/browser/main/tab/page.cpp
  6. 9
      src/app/browser/main/tab/page.hpp

4
src/app/browser/main.cpp

@ -40,7 +40,9 @@ Glib::ustring Main::get_current_tab_label_text()
// Actions // Actions
void Main::tab_append() void Main::tab_append()
{ {
tab->append(); tab->append(
_("New page")
);
}; };
void Main::tab_update() void Main::tab_update()

1
src/app/browser/main.hpp

@ -1,6 +1,7 @@
#ifndef APP_BROWSER_MAIN_HPP #ifndef APP_BROWSER_MAIN_HPP
#define APP_BROWSER_MAIN_HPP #define APP_BROWSER_MAIN_HPP
#include <glibmm/i18n.h>
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
#include <gtkmm/box.h> #include <gtkmm/box.h>

14
src/app/browser/main/tab.cpp

@ -49,16 +49,20 @@ Glib::ustring Tab::get_label_text(
// Actions // Actions
void Tab::append( void Tab::append(
const Glib::ustring & page_navbar_request_text, const Glib::ustring & TITLE,
bool focus const Glib::ustring & REQUEST,
const bool & TAB_FOCUS
) { ) {
auto tabPage = new tab::Page( auto tabPage = new tab::Page(
page_navbar_request_text TITLE,
REQUEST
); );
auto tabLabel = new tab::Label;
int page_number = append_page( int page_number = append_page(
* tabPage, * tabPage,
* new tab::Label * tabLabel
); );
set_tab_reorderable( set_tab_reorderable(
@ -66,7 +70,7 @@ void Tab::append(
REORDERABLE REORDERABLE
); );
if (focus) if (TAB_FOCUS)
{ {
set_current_page( set_current_page(
page_number page_number

5
src/app/browser/main/tab.hpp

@ -23,8 +23,9 @@ namespace app::browser::main
); );
void append( void append(
const Glib::ustring & page_navbar_request_text = "", const Glib::ustring & TITLE,
bool focus = true const Glib::ustring & REQUEST = "",
const bool & TAB_FOCUS = true
); );
void close( void close(

17
src/app/browser/main/tab/page.cpp

@ -6,8 +6,12 @@
using namespace app::browser::main::tab; using namespace app::browser::main::tab;
Page::Page( Page::Page(
const Glib::ustring & navbar_request_text const Glib::ustring & TITLE,
const Glib::ustring & REQUEST
) { ) {
// Init extras
title = TITLE;
// Init container // Init container
set_orientation( set_orientation(
Gtk::Orientation::VERTICAL Gtk::Orientation::VERTICAL
@ -32,7 +36,7 @@ Page::Page(
// Init components // Init components
pageNavbar = new page::Navbar( pageNavbar = new page::Navbar(
navbar_request_text REQUEST
); );
append( append(
@ -63,8 +67,17 @@ Page::~Page()
delete pageProgressbar; delete pageProgressbar;
} }
// Getters
Glib::ustring Page::get_title()
{
return title;
}
// Actions
void Page::update() void Page::update()
{ {
title = _("Loading..");
// Reset progress // Reset progress
pageProgressbar->set( pageProgressbar->set(
0 0

9
src/app/browser/main/tab/page.hpp

@ -27,6 +27,8 @@ namespace app::browser::main::tab
{ {
char buffer[0xfffff]; // 1Mb char buffer[0xfffff]; // 1Mb
Glib::ustring title;
Glib::RefPtr<Gio::SocketClient> GioSocketClient_RefPtr; Glib::RefPtr<Gio::SocketClient> GioSocketClient_RefPtr;
Glib::RefPtr<Gio::SocketConnection> GioSocketConnection_RefPtr; Glib::RefPtr<Gio::SocketConnection> GioSocketConnection_RefPtr;
@ -37,11 +39,16 @@ namespace app::browser::main::tab
public: public:
Page( Page(
const Glib::ustring & navbar_request_text = "" const Glib::ustring & TITLE,
const Glib::ustring & REQUEST = ""
); );
~Page(); ~Page();
// Getters
Glib::ustring get_title();
// Actions
void update(); void update();
}; };
} }

Loading…
Cancel
Save