implement tab width settings

This commit is contained in:
yggverse 2024-04-17 23:47:56 +03:00
parent bdb586144c
commit bb42afd2ce
2 changed files with 40 additions and 10 deletions

View file

@ -25,7 +25,15 @@
{
"title":
{
"default":"New page"
"default":"New page",
"width":
{
"chars":32
},
"ellipsize":
{
"mode":3
}
},
"redirect":
{

View file

@ -763,23 +763,45 @@ class Page
?string $value = null
): void
{
if ($value)
// Build new tab label on title length reached
if ($value && mb_strlen($value) > $this->config->title->width->chars)
{
$title = $value;
$label = new \GtkLabel(
$value ? $value : $this->config->title->default
);
if ($this->config->title->width->chars)
{
$label->set_width_chars(
$this->config->title->width->chars
);
}
if ($this->config->title->ellipsize->mode)
{
$label->set_ellipsize(
// https://docs.gtk.org/Pango/enum.EllipsizeMode.html
$this->config->title->ellipsize->mode
);
}
$this->app->tabs->set_tab_label(
$this->box,
$label
);
}
else
{
$title = $this->config->title->default;
$this->app->tabs->set_tab_label_text(
$this->box,
$value
);
}
$this->app->tabs->set_tab_label_text(
$this->box,
$title
);
// Update window title
$this->app->setTitle(
$title
$value ? $value : $this->config->title->default
);
}