Glib::ustring Document::keyReplaceDialog ( Glib::ustring const &original, Glib::ustring const &replacement, const char *message_text) { Glib::ustring message = String::ucompose ( "<big><b>%1</b></big>\n\n%2", _("Key naming conflict"), String::ucompose ( message_text, original, replacement)); Gtk::MessageDialog dialog (message, true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE, true); Gtk::Button *button; button = dialog.add_button (_("_Ignore"), Gtk::RESPONSE_CANCEL); Gtk::Image *noImage = Gtk::manage (new Gtk::Image (Gtk::Stock::NO, Gtk::ICON_SIZE_BUTTON)); button->set_image (*noImage); button = dialog.add_button (_("_Replace"), Gtk::RESPONSE_ACCEPT); Gtk::Image *yesImage = Gtk::manage (new Gtk::Image (Gtk::Stock::YES, Gtk::ICON_SIZE_BUTTON)); button->set_image (*yesImage); dialog.set_default_response (Gtk::RESPONSE_ACCEPT); if (dialog.run () == Gtk::RESPONSE_ACCEPT) return replacement; else return original; }
// Main constructor SkinPropertyEditor::SkinPropertyEditor(Entity* entity, const std::string& name, const std::string& options) : PropertyEditor(entity), _key(name) { // Construct the main widget (will be managed by the base class) Gtk::VBox* mainVBox = new Gtk::VBox(false, 6); // Register the main widget in the base class setMainWidget(mainVBox); // Horizontal box contains browse button Gtk::HBox* hbx = Gtk::manage(new Gtk::HBox(false, 3)); hbx->set_border_width(3); // Create the browse button Gtk::Button* browseButton = Gtk::manage(new Gtk::Button(_("Choose skin..."))); browseButton->set_image(*Gtk::manage(new Gtk::Image( PropertyEditorFactory::getPixbufFor("skin")))); browseButton->signal_clicked().connect( sigc::mem_fun(*this, &SkinPropertyEditor::_onBrowseButton)); hbx->pack_start(*browseButton, true, false, 0); // Pack hbox into vbox (to limit vertical size), then edit frame Gtk::VBox* vbx = Gtk::manage(new Gtk::VBox(false, 0)); vbx->pack_start(*hbx, true, false, 0); mainVBox->pack_start(*vbx, true, true, 0); }
AIHeadPropertyEditor::AIHeadPropertyEditor(Entity* entity, const std::string& key, const std::string& options) : _entity(entity) { _widget = Gtk::manage(new Gtk::HBox(false, 0)); _widget->set_border_width(6); // Horizontal box contains the browse button Gtk::HBox* hbx = Gtk::manage(new Gtk::HBox(false, 3)); hbx->set_border_width(3); // Browse button for models Gtk::Button* browseButton = Gtk::manage(new Gtk::Button(_("Choose AI head..."))); browseButton->set_image( *Gtk::manage(new Gtk::Image(GlobalUIManager().getLocalPixbuf("icon_model.png"))) ); browseButton->signal_clicked().connect(sigc::mem_fun(*this, &AIHeadPropertyEditor::onChooseButton)); hbx->pack_start(*browseButton, true, false, 0); // Pack hbox into vbox (to limit vertical size), then edit frame Gtk::VBox* vbx = Gtk::manage(new Gtk::VBox(false, 0)); vbx->pack_start(*hbx, true, false, 0); _widget->pack_start(*vbx, true, true, 0); }
// Main constructor TexturePropertyEditor::TexturePropertyEditor(Entity* entity, const std::string& name, const std::string& options) : PropertyEditor(entity), _prefixes(options), _key(name) { // Construct the main widget (will be managed by the base class) Gtk::VBox* mainVBox = new Gtk::VBox(false, 6); // Register the main widget in the base class setMainWidget(mainVBox); Gtk::VBox* outer = Gtk::manage(new Gtk::VBox(false, 0)); Gtk::HBox* editBox = Gtk::manage(new Gtk::HBox(false, 3)); // Create the browse button Gtk::Button* browseButton = Gtk::manage(new Gtk::Button(_("Choose texture..."))); browseButton->set_image(*Gtk::manage(new Gtk::Image( PropertyEditorFactory::getPixbufFor("texture")))); browseButton->signal_clicked().connect( sigc::mem_fun(*this, &TexturePropertyEditor::_onBrowse)); editBox->pack_start(*browseButton, true, false, 0); outer->pack_start(*editBox, true, false, 0); mainVBox->pack_start(*outer, true, true, 0); }
Gtk::Button* BuilderListToolBoxImpl::createImageStockButton( Gtk::StockID StockImage, Glib::ustring TooltipText) { Gtk::Button* Button = Gtk::manage(new Gtk::Button()); Button->set_image(*Gtk::manage(new Gtk::Image(StockImage, Gtk::ICON_SIZE_BUTTON))); if (TooltipText != "") Button->set_tooltip_text(TooltipText); return Button; }
//------------------------------------------------------------------------------ void mforms::gtk::ToolBarImpl::set_item_icon(mforms::ToolBarItem *item, const std::string &image_path) { Gtk::Button *btn = cast<Gtk::Button *>(item->get_data_ptr()); if (btn) { static ImageCache *images = ImageCache::get_instance(); Gtk::Image *img = new Gtk::Image(images->image_from_path(image_path)); if (img) { btn->set_image(*img); btn->set_data("icon", img, free_icon); img->show(); } } }
// Main constructor ModelPropertyEditor::ModelPropertyEditor(Entity* entity, const std::string& name, const std::string& options) : PropertyEditor(entity), _key(name) { // Construct the main widget (will be managed by the base class) Gtk::VBox* mainVBox = new Gtk::VBox(false, 6); // Register the main widget in the base class setMainWidget(mainVBox); // Horizontal box contains the browse button Gtk::HBox* hbx = Gtk::manage(new Gtk::HBox(false, 3)); hbx->set_border_width(3); // Browse button for models Gtk::Button* browseButton = Gtk::manage(new Gtk::Button(_("Choose model..."))); browseButton->set_image(*Gtk::manage(new Gtk::Image( PropertyEditorFactory::getPixbufFor("model")))); browseButton->signal_clicked().connect(sigc::mem_fun(*this, &ModelPropertyEditor::_onModelButton)); // Browse button for particles Gtk::Button* particleButton = Gtk::manage(new Gtk::Button(_("Choose particle..."))); particleButton->set_image(*Gtk::manage(new Gtk::Image( GlobalUIManager().getLocalPixbuf("particle16.png")))); particleButton->signal_clicked().connect(sigc::mem_fun(*this, &ModelPropertyEditor::_onParticleButton)); hbx->pack_start(*browseButton, true, false, 0); hbx->pack_start(*particleButton, true, false, 0); // Pack hbox into vbox (to limit vertical size), then edit frame Gtk::VBox* vbx = Gtk::manage(new Gtk::VBox(false, 0)); vbx->pack_start(*hbx, true, false, 0); mainVBox->pack_start(*vbx, true, true, 0); }
void HIGMessageDialog::add_button (const Glib::RefPtr<Gdk::Pixbuf> & pixbuf, const Glib::ustring & label_text, Gtk::ResponseType resp, bool is_default) { Gtk::Button *button = manage(new Gtk::Button()); Gtk::Image *image = manage(new Gtk::Image(pixbuf)); // NOTE: This property is new to GTK+ 2.10, but we don't // really need the line because we're just setting // it to the default value anyway. //button.ImagePosition = Gtk::PositionType.Left; button->set_image(*image); button->set_label(label_text); button->set_use_underline(true); button->property_can_default().set_value(true); add_button (button, resp, is_default); }
Gobby::GotoDialog::GotoDialog(Gtk::Window& parent, const Folder& folder): Gtk::Dialog(_("Go to line"), parent), m_folder(folder), m_table(1, 2), m_label_line(_("Line _number:"), GtkCompat::ALIGN_LEFT, Gtk::ALIGN_CENTER, true), m_current_view(NULL) { m_label_line.set_mnemonic_widget(m_entry_line); m_label_line.show(); m_entry_line.set_increments(1, 10); m_entry_line.set_activates_default(true); m_entry_line.show(); m_table.attach(m_label_line, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); m_table.attach(m_entry_line, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); m_table.set_spacings(12); m_table.show(); get_vbox()->pack_start(m_table, Gtk::PACK_EXPAND_WIDGET); add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE); Gtk::Button* button = add_button(_("Go To _Line"), Gtk::RESPONSE_ACCEPT); button->set_image(*Gtk::manage(new Gtk::Image( Gtk::Stock::JUMP_TO, Gtk::ICON_SIZE_BUTTON))); m_folder.signal_document_changed().connect( sigc::mem_fun(*this, &GotoDialog::on_document_changed)); set_default_response(Gtk::RESPONSE_ACCEPT); set_border_width(12); set_resizable(false); // For initial sensitivity: on_document_changed(m_folder.get_current_document()); }