Como justificar o conteudo de um GtkLabel
Solução
Existe um método chamado set_justify(tipo). Nele é passado 1 parâmetro dizendo qual a direção do texto.
Os valores são: Gtk::JUSTIFY_LEFT, Gtk::JUSTIFY_RIGHT, Gtk::JUSTIFY_CENTER ou Gtk::JUSTIFY_FILL.
Exemplo
<?php
// Classe de testes
class Teste
{
// Vetor que armazena todos os widgets da interface
public $widgets = array();
// Construtor da classe
public function __construct()
{
// Cria o container
$fixed = new GtkFixed();
// Cria o Label
$this->widgets['lblTeste'] = new GtkLabel("Meu label\njustificado.");
$this->widgets['lblTeste']->set_size_request(100, 50);
$fixed->put($this->widgets['lblTeste'], 8, 8);
// Justifica o texto
$this->widgets['lblTeste']->set_justify(Gtk::JUSTIFY_RIGHT);
// Cria a janela
$this->widgets['frmTeste'] = new GtkWindow();
$this->widgets['frmTeste']->set_size_request(116, 66);
$this->widgets['frmTeste']->set_resizable(FALSE);
$this->widgets['frmTeste']->set_title("Teste");
$this->widgets['frmTeste']->add($fixed);
$this->widgets['frmTeste']->set_position(GTK::WIN_POS_CENTER);
$this->widgets['frmTeste']->show_all();
// Conecta o destroy
$this->widgets['frmTeste']->connect_simple(
"destroy",
array("Gtk", "main_quit")
);
}
}
// Classe de testes
class Teste
{
// Vetor que armazena todos os widgets da interface
public $widgets = array();
// Construtor da classe
public function __construct()
{
// Cria o container
$fixed = new GtkFixed();
// Cria o Label
$this->widgets['lblTeste'] = new GtkLabel("Meu label\njustificado.");
$this->widgets['lblTeste']->set_size_request(100, 50);
$fixed->put($this->widgets['lblTeste'], 8, 8);
// Justifica o texto
$this->widgets['lblTeste']->set_justify(Gtk::JUSTIFY_RIGHT);
// Cria a janela
$this->widgets['frmTeste'] = new GtkWindow();
$this->widgets['frmTeste']->set_size_request(116, 66);
$this->widgets['frmTeste']->set_resizable(FALSE);
$this->widgets['frmTeste']->set_title("Teste");
$this->widgets['frmTeste']->add($fixed);
$this->widgets['frmTeste']->set_position(GTK::WIN_POS_CENTER);
$this->widgets['frmTeste']->show_all();
// Conecta o destroy
$this->widgets['frmTeste']->connect_simple(
"destroy",
array("Gtk", "main_quit")
);
}
}
// Inicia a aplicação
$teste = new Teste();
gtk::main();
Explicação
Com as constantes Gtk, é possível justificar seu texto para o sentido necessário.
Referências
http://gtk.php.net/manual/en/gtk.gtklabel.method.set_justify.php
http://gtk.php.net/manual/en/gtk.enum.justification.php