本文整理汇总了C++中IEvent::connectWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ IEvent::connectWidget方法的具体用法?C++ IEvent::connectWidget怎么用?C++ IEvent::connectWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEvent
的用法示例。
在下文中一共展示了IEvent::connectWidget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createToolItem
/* Checks the passed xmlNode for a recognized item (ToolButton, ToggleToolButton, Separator)
* Returns the widget or NULL if nothing useful is found
*/
GtkWidget* ToolbarCreator::createToolItem(xml::Node& node, GtkToolbar* toolbar) {
const std::string nodeName = node.getName();
GtkWidget* toolItem;
if (nodeName == "separator") {
toolItem = GTK_WIDGET(gtk_separator_tool_item_new());
}
else if (nodeName == "toolbutton" || nodeName == "toggletoolbutton") {
// Found a button, load the values that are shared by both types
const std::string name = node.getAttributeValue("name");
const std::string icon = node.getAttributeValue("icon");
const std::string tooltip = _(node.getAttributeValue("tooltip").c_str());
const std::string action = node.getAttributeValue("action");
if (nodeName == "toolbutton") {
// Create a new GtkToolButton and assign the right callback
toolItem = GTK_WIDGET(gtk_tool_button_new(NULL, name.c_str()));
}
else {
// Create a new GtkToggleToolButton and assign the right callback
toolItem = GTK_WIDGET(gtk_toggle_tool_button_new());
}
IEvent* event = GlobalEventManager().findEvent(action);
if (event != NULL) {
event->connectWidget(GTK_WIDGET(toolItem));
// Tell the event to update the state of this button
event->updateWidgets();
} else {
globalErrorStream() << "ToolbarCreator: Failed to lookup command " << action << "\n";
}
// Set the tooltip, if not empty
if (!tooltip.empty()) {
gtk_tooltips_set_tip(_tooltips, GTK_WIDGET(toolItem), tooltip.c_str(), "");
//gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolItem), _tooltips, tooltip.c_str(), "");
}
// Load and assign the icon, if specified
if (icon != "") {
GtkWidget* image = gtk_image_new_from_pixbuf(gtkutil::getLocalPixbufWithMask(icon));
gtk_widget_show(image);
gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(toolItem), image);
}
}
else {
return NULL;
}
gtk_widget_show(toolItem);
return toolItem;
}