本文整理汇总了C++中gtk::Label::gobj方法的典型用法代码示例。如果您正苦于以下问题:C++ Label::gobj方法的具体用法?C++ Label::gobj怎么用?C++ Label::gobj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk::Label
的用法示例。
在下文中一共展示了Label::gobj方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Label
Gobby::StatusBar::MessageHandle
Gobby::StatusBar::add_message(Gobby::StatusBar::MessageType type,
const Glib::ustring& message,
const Glib::ustring& dialog_message,
unsigned int timeout)
{
if(m_visible_messages >= 12)
{
for(MessageHandle iter = m_list.begin();
iter != m_list.end();
++iter)
{
if(*iter)
{
if((*iter)->is_error())
remove_message(iter);
else
// only hide message because whoever
// installed it is expecting to be
// able to call remove_message on it
hide_message(iter);
break;
}
}
}
Gtk::Grid* grid = Gtk::manage(new Gtk::Grid());
grid->set_column_spacing(6);
grid->set_margin_start(2);
grid->set_margin_end(2);
Gtk::Image* image = Gtk::manage(new Gtk::Image);
image->set_from_icon_name(message_type_to_icon_name(type),
Gtk::ICON_SIZE_MENU);
grid->attach(*image, 0, 0, 1, 1);
image->show();
Gtk::Label* label = Gtk::manage(
new Gtk::Label(message, Gtk::ALIGN_START));
label->set_ellipsize(Pango::ELLIPSIZE_END);
// If we set halign instead, the label will not behave correctly
// when ellipsized, because then it has always all space around it
// allocated, and the alignment "jumps" around whin resizing the
// window due to new characters appearing or disappearing as a result
// of the ellipsization.
#if GTK_CHECK_VERSION(3, 16, 0)
gtk_label_set_xalign(label->gobj(), 0.0);
#else
label->set_alignment(0.0, 0.0);
#endif
label->show();
grid->attach(*label, 1, 0, 1, 1);
Gtk::Frame* frame = Gtk::manage(new Gtk::Frame);
m_list.push_back(0);
Gobby::StatusBar::MessageHandle iter(--m_list.end());
sigc::connection timeout_conn;
if(timeout)
{
timeout_conn = Glib::signal_timeout().connect_seconds(
sigc::bind(
sigc::bind_return(
sigc::mem_fun(
*this,
&StatusBar::remove_message),
false),
iter),
timeout);
}
*iter = new Message(frame, message, dialog_message, timeout_conn);
++m_visible_messages;
if(dialog_message.empty())
{
frame->add(*grid);
}
else
{
Gtk::EventBox *eventbox = Gtk::manage(new Gtk::EventBox);
frame->add(*eventbox);
eventbox->add(*grid);
eventbox->signal_button_press_event().connect(
sigc::bind_return(sigc::bind(
sigc::mem_fun(
*this,
&StatusBar::on_message_clicked),
iter), false));
eventbox->show();
}
grid->show();
// Insert at front
gtk_grid_attach_next_to(
gobj(), GTK_WIDGET(frame->gobj()),
NULL, GTK_POS_LEFT, 1, 1);
//.........这里部分代码省略.........