mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-06 08:24:14 +00:00
implement title detection by content type provider
This commit is contained in:
parent
5e88040bf0
commit
f31dc84fe6
@ -316,6 +316,12 @@ void Page::navigation_reload(
|
|||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Update title on detected by document provider
|
||||||
|
if (!pageContent->get_title().empty())
|
||||||
|
{
|
||||||
|
title = pageContent->get_title();
|
||||||
|
}
|
||||||
|
|
||||||
action__update->activate();
|
action__update->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,12 @@ Content::~Content()
|
|||||||
delete contentText;
|
delete contentText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
Glib::ustring Content::get_title()
|
||||||
|
{
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
void Content::update(
|
void Content::update(
|
||||||
const MIME & MIME,
|
const MIME & MIME,
|
||||||
@ -39,6 +45,8 @@ void Content::update(
|
|||||||
// Cleanup, free memory
|
// Cleanup, free memory
|
||||||
if (contentText != nullptr)
|
if (contentText != nullptr)
|
||||||
{
|
{
|
||||||
|
title.clear();
|
||||||
|
|
||||||
remove(
|
remove(
|
||||||
* contentText
|
* contentText
|
||||||
);
|
);
|
||||||
@ -58,6 +66,8 @@ void Content::update(
|
|||||||
DATA
|
DATA
|
||||||
);
|
);
|
||||||
|
|
||||||
|
title = contentText->get_title();
|
||||||
|
|
||||||
append(
|
append(
|
||||||
* contentText
|
* contentText
|
||||||
);
|
);
|
||||||
|
@ -22,8 +22,11 @@ namespace app::browser::main::tab::page
|
|||||||
// Components
|
// Components
|
||||||
content::Text * contentText;
|
content::Text * contentText;
|
||||||
|
|
||||||
|
// Extra features
|
||||||
|
Glib::ustring title;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class API
|
* Content class API
|
||||||
*/
|
*/
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -36,10 +39,14 @@ namespace app::browser::main::tab::page
|
|||||||
Content();
|
Content();
|
||||||
~Content();
|
~Content();
|
||||||
|
|
||||||
|
// Actions
|
||||||
void update(
|
void update(
|
||||||
const MIME & MIME,
|
const MIME & MIME,
|
||||||
const Glib::ustring & DATA
|
const Glib::ustring & DATA
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
Glib::ustring get_title();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ Text::Text(
|
|||||||
|
|
||||||
set_child(
|
set_child(
|
||||||
* Gtk::make_managed<text::Gemini>(
|
* Gtk::make_managed<text::Gemini>(
|
||||||
TEXT
|
TEXT,
|
||||||
|
title
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -34,4 +35,10 @@ Text::Text(
|
|||||||
|
|
||||||
throw _("Invalid text type enum"); // @TODO
|
throw _("Invalid text type enum"); // @TODO
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
Glib::ustring Text::get_title()
|
||||||
|
{
|
||||||
|
return title;
|
||||||
}
|
}
|
@ -9,18 +9,32 @@ namespace app::browser::main::tab::page::content
|
|||||||
{
|
{
|
||||||
class Text : public Gtk::ScrolledWindow
|
class Text : public Gtk::ScrolledWindow
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Private members
|
||||||
|
*/
|
||||||
|
Glib::ustring title;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extra features
|
||||||
|
*/
|
||||||
enum Type
|
enum Type
|
||||||
{
|
{
|
||||||
GEMINI,
|
GEMINI,
|
||||||
PLAIN
|
PLAIN
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Text class API
|
||||||
|
*/
|
||||||
Text(
|
Text(
|
||||||
const Type & TYPE,
|
const Type & TYPE,
|
||||||
const Glib::ustring & TEXT
|
const Glib::ustring & TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
Glib::ustring get_title();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,19 +4,26 @@
|
|||||||
using namespace app::browser::main::tab::page::content::text;
|
using namespace app::browser::main::tab::page::content::text;
|
||||||
|
|
||||||
Gemini::Gemini(
|
Gemini::Gemini(
|
||||||
const Glib::ustring & GEMTEXT
|
const Glib::ustring & GEMTEXT,
|
||||||
|
Glib::ustring & title
|
||||||
) : Gtk::Viewport( // add scrolled window features to childs
|
) : Gtk::Viewport( // add scrolled window features to childs
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
) {
|
) {
|
||||||
|
// Init components
|
||||||
|
auto geminiReader = Gtk::make_managed<gemini::Reader>(
|
||||||
|
GEMTEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
// Grab title
|
||||||
|
title = geminiReader->get_title();
|
||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
set_scroll_to_focus(
|
set_scroll_to_focus(
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
set_child(
|
set_child(
|
||||||
* Gtk::make_managed<gemini::Reader>(
|
* geminiReader
|
||||||
GEMTEXT
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
@ -8,10 +8,14 @@ namespace app::browser::main::tab::page::content::text
|
|||||||
{
|
{
|
||||||
class Gemini : public Gtk::Viewport
|
class Gemini : public Gtk::Viewport
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Gemini class API
|
||||||
|
*/
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Gemini(
|
Gemini(
|
||||||
const Glib::ustring & GEMTEXT
|
const Glib::ustring & GEMTEXT,
|
||||||
|
Glib::ustring & title
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,12 @@ Reader::Reader(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
Glib::ustring Reader::get_title()
|
||||||
|
{
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
// Match tools
|
// Match tools
|
||||||
bool Reader::Line::Match::header(
|
bool Reader::Line::Match::header(
|
||||||
const Glib::ustring & GEMTEXT,
|
const Glib::ustring & GEMTEXT,
|
||||||
@ -152,6 +158,11 @@ Glib::ustring Reader::make(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (title.empty())
|
||||||
|
{
|
||||||
|
title = header;
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,18 +62,26 @@ namespace app::browser::main::tab::page::content::text::gemini
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
static Glib::ustring make(
|
Glib::ustring make(
|
||||||
const Glib::ustring & GEMTEXT
|
const Glib::ustring & GEMTEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gemini class API
|
* Private members
|
||||||
|
*/
|
||||||
|
Glib::ustring title;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reader class API
|
||||||
*/
|
*/
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Reader(
|
Reader(
|
||||||
const Glib::ustring & GEMTEXT
|
const Glib::ustring & GEMTEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
Glib::ustring get_title();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user