Browse Source

add page title support, make arguments linked const

CPP-GTK4
yggverse 4 months ago
parent
commit
c75744f777
  1. 4
      src/app/browser/main.cpp
  2. 1
      src/app/browser/main.hpp
  3. 16
      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() @@ -40,7 +40,9 @@ Glib::ustring Main::get_current_tab_label_text()
// Actions
void Main::tab_append()
{
tab->append();
tab->append(
_("New page")
);
};
void Main::tab_update()

1
src/app/browser/main.hpp

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save