mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
rename widgets
This commit is contained in:
parent
38b2ac4f04
commit
57f43e2dd9
28 changed files with 365 additions and 365 deletions
106
src/app/browser/main/tab/page/navigation/request.cpp
Normal file
106
src/app/browser/main/tab/page/navigation/request.cpp
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
#include "request.hpp"
|
||||
|
||||
using namespace app::browser::main::tab::page::navigation;
|
||||
|
||||
// Construct
|
||||
Request::Request(
|
||||
const Glib::ustring & TEXT
|
||||
) {
|
||||
// Init entry
|
||||
set_placeholder_text(
|
||||
_("URL or search term...")
|
||||
);
|
||||
|
||||
set_hexpand(
|
||||
HEXPAND
|
||||
);
|
||||
|
||||
if (!TEXT.empty())
|
||||
{
|
||||
set_text(
|
||||
TEXT
|
||||
);
|
||||
|
||||
parse();
|
||||
}
|
||||
|
||||
// Connect events
|
||||
signal_changed().connect(
|
||||
[this]
|
||||
{
|
||||
parse();
|
||||
|
||||
activate_action(
|
||||
"navigation.refresh"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
signal_activate().connect(
|
||||
[this]
|
||||
{
|
||||
parse();
|
||||
|
||||
activate_action(
|
||||
"page.update"
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Getters
|
||||
Glib::ustring Request::get_scheme()
|
||||
{
|
||||
return scheme;
|
||||
}
|
||||
|
||||
Glib::ustring Request::get_host()
|
||||
{
|
||||
return host;
|
||||
}
|
||||
|
||||
Glib::ustring Request::get_port()
|
||||
{
|
||||
return port;
|
||||
}
|
||||
|
||||
Glib::ustring Request::get_path()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
Glib::ustring Request::get_query()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
// Private helpers
|
||||
void Request::parse()
|
||||
{
|
||||
auto match = Glib::Regex::split_simple(
|
||||
R"regex(^((\w+)?:\/\/)?([^:\/]+)?(:(\d+)?)?([^\?$]+)?(\?(.*)?)?)regex",
|
||||
get_text()
|
||||
);
|
||||
|
||||
scheme = "";
|
||||
host = "";
|
||||
port = "";
|
||||
path = "";
|
||||
query = "";
|
||||
|
||||
int index = 0;
|
||||
|
||||
for (const Glib::ustring & VALUE : match)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 2: scheme = VALUE; break;
|
||||
case 3: host = VALUE; break;
|
||||
case 5: port = VALUE; break;
|
||||
case 6: path = VALUE; break;
|
||||
case 8: query = VALUE; break;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue