
Enviado em 20/10/2017 - 22:09h
Boa noite a todos,#include <iostream>
#include <thread>
#include <unistd.h>
#include <gtkmm.h>
void imprimir(bool *estado, Gtk::TextView *visao_de_texto, Glib::RefPtr <Gtk::TextBuffer> buffer_de_texto)
{
for ( size_t segundos = 1;
*estado;
segundos++ )
{
sleep(1);
buffer_de_texto->insert(buffer_de_texto->end(), std::string("Dormir ") + std::to_string(segundos) + std::string(" segundos...\n"));
// Minha tentativa
visao_de_texto->scroll_to(buffer_de_texto->get_insert(), 0, 0, 0);
}
}
int main(int argc, char *argv[])
{
Glib::RefPtr <Gtk::Application> aplicacao = Gtk::Application::create(argc, argv, "Exemplo.com");
// TextBuffer
Glib::RefPtr <Gtk::TextBuffer> buffer_de_texto = Gtk::TextBuffer::create();
// TextView
Gtk::TextView visao_de_texto;
visao_de_texto.property_editable() = false;
visao_de_texto.set_buffer(buffer_de_texto);
visao_de_texto.show();
// ScrolledWindow
Gtk::ScrolledWindow janela_de_rolamento;
janela_de_rolamento.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
janela_de_rolamento.add(visao_de_texto);
janela_de_rolamento.show();
// Window
Gtk::Window janela;
janela.set_default_size(320, 240);
janela.add(janela_de_rolamento);
janela.show();
// Thread
bool estado = true;
std::thread thread(imprimir, &estado, &visao_de_texto, buffer_de_texto);
// Resultado
int resultado = aplicacao->run(janela);
estado = false;
thread.join();
return resultado;
}
g++ -O2 -std=c++11 -pedantic-errors -Wall -Werror -Wextra -fstack-protector-all -pthread `pkg-config --cflags --libs gtkmm-3.0` teste.cpp -o teste.run
Trabalhando Nativamente com Logs no Linux
Jogando Daikatana (Steam) com Patch 1.3 via Luxtorpeda no Linux
LazyDocker – Interface de Usuário em Tempo Real para o Docker
Apagar Todo o Histórico do Terminal
Linux Mint: Zram + Swapfile em Btrfs
Internet não funciona corretamente no Linux (3)
Pendrive do Ubuntu 24.04 travando ao tentar fazer a instalação dual bo... (4)
Instalar Dual Boot, Linux+Windows. (14)
queria saber de uma coisa sobre o steam e derivados (3)
tentei instalar o steam pelo terminal, agora ele não abre (3)









