Browse Source

implement tab width settings

PHP-GTK3
yggverse 8 months ago
parent
commit
bb42afd2ce
  1. 10
      config.json
  2. 34
      src/Entity/Tab/Page.php

10
config.json

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

34
src/Entity/Tab/Page.php

@ -763,23 +763,45 @@ class Page @@ -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
);
}
else
if ($this->config->title->ellipsize->mode)
{
$title = $this->config->title->default;
$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
{
$this->app->tabs->set_tab_label_text(
$this->box,
$title
$value
);
}
// Update window title
$this->app->setTitle(
$title
$value ? $value : $this->config->title->default
);
}

Loading…
Cancel
Save