/************************************************************* * POPUP INITIALIZER *************************************************************/ void ImportDialog::init () { bool fine = true; // Load the GtkBuilder file and instantiate its widgets: Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create(); try { if(access("/usr/local/share/jderobot/glade/visualHFSM/import.glade", F_OK) == 0){ refBuilder->add_from_file("/usr/local/share/jderobot/glade/visualHFSM/import.glade"); }else{ refBuilder->add_from_file("gui/import.glade"); } } catch (const Glib::FileError& ex) { std::cerr << BEGIN_RED << "FileError: " << ex.what() << END_COLOR << std::endl; fine = false; } catch(const Glib::MarkupError& ex) { std::cerr << BEGIN_RED << "MarkupError: " << ex.what() << END_COLOR << std::endl; fine = false; } catch(const Gtk::BuilderError& ex) { std::cerr << BEGIN_RED << "BuilderError: " << ex.what() << END_COLOR << std::endl; fine = false; } if (fine) { refBuilder->get_widget("dialog_import", this->dialog); refBuilder->get_widget("button_accept", this->button_accept); refBuilder->get_widget("button_cancel", this->button_cancel); refBuilder->get_widget("checkbutton_laser", this->checkbutton_laser); refBuilder->get_widget("checkbutton_sonar", this->checkbutton_sonar); refBuilder->get_widget("checkbutton_camera", this->checkbutton_camera); refBuilder->get_widget("checkbutton_pose3dencoders", this->checkbutton_pose3dencoders); refBuilder->get_widget("checkbutton_pose3dmotors", this->checkbutton_pose3dmotors); if (gsubautomata->findInterface(std::string("laser"))) this->checkbutton_laser->set_active(true); if (gsubautomata->findInterface(std::string("sonar"))) this->checkbutton_sonar->set_active(true); if (gsubautomata->findInterface(std::string("camera"))) this->checkbutton_camera->set_active(true); if (gsubautomata->findInterface(std::string("pose3dencoders"))) this->checkbutton_pose3dencoders->set_active(true); if (gsubautomata->findInterface(std::string("pose3dmotors"))) this->checkbutton_pose3dmotors->set_active(true); this->button_accept->signal_clicked().connect(sigc::mem_fun(this, &ImportDialog::on_button_accept)); this->button_cancel->signal_clicked().connect(sigc::mem_fun(this, &ImportDialog::on_button_cancel)); this->dialog->add_events(Gdk::KEY_PRESS_MASK); this->dialog->signal_key_release_event().connect(sigc::mem_fun(this, &ImportDialog::on_key_released)); this->dialog->show_now(); } }
MainWindow* MainWindow::CreateFromBuilder() { //Load the Glade file and instiate its widgets: Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create(); try { refBuilder->add_from_file("res/mainwindow.glade"); } catch(const Glib::FileError& ex) { std::cerr << "FileError: " << ex.what() << std::endl; return NULL; } catch(const Glib::MarkupError& ex) { std::cerr << "MarkupError: " << ex.what() << std::endl; return NULL; } catch(const Gtk::BuilderError& ex) { std::cerr << "BuilderError: " << ex.what() << std::endl; return NULL; } MainWindow* pWindow = NULL; refBuilder->get_widget_derived<MainWindow>("mainwindow", pWindow); return pWindow; }
/************************************************************* * POPUP INITIALIZER *************************************************************/ void EditNodeDialog::init () { bool fine = true; // Load the GtkBuilder file and instantiate its widgets: Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create(); try { refBuilder->add_from_file("gui/code.glade"); } catch (const Glib::FileError& ex) { std::cerr << BEGIN_RED << "FileError: " << ex.what() << END_COLOR << std::endl; fine = false; } catch(const Glib::MarkupError& ex) { std::cerr << BEGIN_RED << "MarkupError: " << ex.what() << END_COLOR << std::endl; fine = false; } catch(const Gtk::BuilderError& ex) { std::cerr << BEGIN_RED << "BuilderError: " << ex.what() << END_COLOR << std::endl; fine = false; } if (fine) { refBuilder->get_widget("dialog_code", this->dialog); refBuilder->get_widget("button_accept", this->button_accept); refBuilder->get_widget("button_cancel", this->button_cancel); refBuilder->get_widget("textview", this->textview); Glib::RefPtr<Gtk::TextBuffer> textbuffer = Gtk::TextBuffer::create(); textbuffer->set_text(this->gnode->getCode()); this->textview->set_buffer(textbuffer); this->button_accept->signal_clicked().connect(sigc::mem_fun(this, &EditNodeDialog::on_button_accept)); this->button_cancel->signal_clicked().connect(sigc::mem_fun(this, &EditNodeDialog::on_button_cancel)); this->dialog->show_now(); } }
/************************************************************* * POPUP INITIALIZER *************************************************************/ void EditTransitionDialog::init () { bool fine = true; // Load the GtkBuilder file and instantiate its widgets: Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create(); const std::string gladepath = resourcelocator::findGladeFile("edittransition.glade"); try{ refBuilder->add_from_file(gladepath); } catch (const Glib::FileError& ex) { std::cerr << BEGIN_RED << "FileError: " << ex.what() << END_COLOR << std::endl; fine = false; } catch(const Glib::MarkupError& ex) { std::cerr << BEGIN_RED << "MarkupError: " << ex.what() << END_COLOR << std::endl; fine = false; } catch(const Gtk::BuilderError& ex) { std::cerr << BEGIN_RED << "BuilderError: " << ex.what() << END_COLOR << std::endl; fine = false; } if (fine) { refBuilder->get_widget("dialog_edittransition", this->dialog); refBuilder->get_widget("button_accept", this->button_accept); refBuilder->get_widget("button_cancel", this->button_cancel); refBuilder->get_widget("entry_text", this->entry_text); refBuilder->get_widget("label_frame", this->label_frame); refBuilder->get_widget("radiobutton_temporal", this->radiobutton_temporal); refBuilder->get_widget("radiobutton_conditional", this->radiobutton_conditional); Gtk::RadioButton::Group group = this->radiobutton_temporal->get_group(); this->radiobutton_conditional->set_group(group); this->radiobutton_temporal->signal_clicked().connect(sigc::mem_fun(this, &EditTransitionDialog::on_radio_temporal_clicked)); this->radiobutton_conditional->signal_clicked().connect(sigc::mem_fun(this, &EditTransitionDialog::on_radio_conditional_clicked)); if (this->gtransition->getTypeTrans().compare("condition") == 0) { this->on_radio_conditional_clicked(); this->radiobutton_conditional->set_active(); } else { this->on_radio_temporal_clicked(); this->radiobutton_temporal->set_active(); } this->entry_text->set_text(this->gtransition->getCodeTrans()); this->button_accept->signal_clicked().connect(sigc::mem_fun(this, &EditTransitionDialog::on_button_accept)); this->button_cancel->signal_clicked().connect(sigc::mem_fun(this, &EditTransitionDialog::on_button_cancel)); this->dialog->add_events(Gdk::KEY_PRESS_MASK); this->dialog->signal_key_release_event().connect(sigc::mem_fun(this, &EditTransitionDialog::on_key_released)); this->dialog->show_now(); } }
int main (int argc, char **argv) { Gtk::Main kit(argc, argv); Gtk::GL::init(argc, argv); // // Query OpenGL extension version. // int major, minor; Gdk::GL::query_version(major, minor); std::cout << "Tiuque::glx version::"<< major << "." << minor << std::endl; //Load the GtkBuilder file and instantiate its widgets: Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create(); #ifdef GLIBMM_EXCEPTIONS_ENABLED try{ refBuilder->add_from_file("tiuque.glade"); } catch(const Glib::FileError& ex){ std::cerr << "FileError: " << ex.what() << std::endl; return 1; } catch(const Gtk::BuilderError& ex){ std::cerr << "BuilderError: " << ex.what() << std::endl; return 1; } #else std::auto_ptr<Glib::Error> error; if (!refBuilder->add_from_file("tiuque.glade", error)){ std::cerr << error->what() << std::endl; return 1; } #endif /* !GLIBMM_EXCEPTIONS_ENABLED */ //Get the GtkBuilder-instantiated Dialog: Application* myApp; refBuilder->get_widget_derived("application", myApp); if(myApp){ myApp->init(); kit.run(*myApp); } return 0; }
conexion::conexion() { Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create(); refBuilder->add_from_file("./conexion.glade"); refBuilder->get_widget("conexion", main); // linkeo el form refBuilder->get_widget("usuarioTxt", usuarioTextBox); refBuilder->get_widget("passTxt", passTextBox); refBuilder->get_widget("conectar", botonConectar); botonConectar->signal_clicked().connect(sigc::mem_fun(*this, &conexion::on_buttonConectar_clicked)); refBuilder->get_widget("Salir", botonSalir); botonSalir->signal_clicked().connect(sigc::mem_fun(*this, &conexion::on_buttonSalir_clicked)); main->show_all_children(); }//justo m llamaron a ver
int main(int argc, char **argv) { Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv); Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create(); refBuilder->add_from_file(UI_FILE); Manager* topWindow; refBuilder->get_widget_derived("topWindow", topWindow); if(topWindow) { app->run(*topWindow); } delete topWindow; return 0; }
/************************************************************* * POPUP INITIALIZER *************************************************************/ void FunVarDialog::init () { bool fine = true; // Load the GtkBuilder file and instantiate its widgets: Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create(); try { refBuilder->add_from_file("gui/funvar.glade"); } catch (const Glib::FileError& ex) { std::cerr << BEGIN_RED << "FileError: " << ex.what() << END_COLOR << std::endl; fine = false; } catch(const Glib::MarkupError& ex) { std::cerr << BEGIN_RED << "MarkupError: " << ex.what() << END_COLOR << std::endl; fine = false; } catch(const Gtk::BuilderError& ex) { std::cerr << BEGIN_RED << "BuilderError: " << ex.what() << END_COLOR << std::endl; fine = false; } if (fine) { refBuilder->get_widget("dialog_funvar", this->dialog); refBuilder->get_widget("textview_functions", this->textview_functions); refBuilder->get_widget("textview_variables", this->textview_variables); refBuilder->get_widget("button_accept", this->button_accept); refBuilder->get_widget("button_cancel", this->button_cancel); Glib::RefPtr<Gtk::TextBuffer> textbufferFunctions = Gtk::TextBuffer::create(); textbufferFunctions->set_text(this->gsubautomata->getFunctions()); this->textview_functions->set_buffer(textbufferFunctions); Glib::RefPtr<Gtk::TextBuffer> textbufferVariables = Gtk::TextBuffer::create(); textbufferVariables->set_text(this->gsubautomata->getVariables()); this->textview_variables->set_buffer(textbufferVariables); this->button_accept->signal_clicked().connect(sigc::mem_fun(this, &FunVarDialog::on_button_accept)); this->button_cancel->signal_clicked().connect(sigc::mem_fun(this, &FunVarDialog::on_button_cancel)); this->dialog->show_now(); } }
int main(int argc, char **argv) { Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.exampleCSS"); Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create(); try{ refBuilder->add_from_file( "main.glade" ); }catch(const Gtk::BuilderError& ex){ std::cerr << "FileError: " << ex.what() << std::endl; return 1; }catch(const Glib::FileError& ex){ std::cerr << "FileError: " << ex.what() << std::endl; return 1; } Gtk::ApplicationWindow* appWindow ; refBuilder->get_widget("appWindow", appWindow); app->register_application(); //load css Glib::RefPtr<Gtk::CssProvider> cssProvider = Gtk::CssProvider::create(); cssProvider->load_from_path("style.css"); Glib::RefPtr<Gtk::StyleContext> styleContext = Gtk::StyleContext::create(); //get default screen Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default(); //add provider for screen in all application styleContext->add_provider_for_screen(screen,cssProvider,GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); app->run(*appWindow); delete appWindow; return 0; }
/************************************************************* * POPUP INITIALIZER *************************************************************/ void TimerDialog::init () { bool fine = true; // Load the GtkBuilder file and instantiate its widgets: Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create(); const std::string gladepath = resourcelocator::findGladeFile("timing.glade"); try{ refBuilder->add_from_file(gladepath); } catch (const Glib::FileError& ex) { std::cerr << BEGIN_RED << "FileError: " << ex.what() << END_COLOR << std::endl; fine = false; } catch(const Glib::MarkupError& ex) { std::cerr << BEGIN_RED << "MarkupError: " << ex.what() << END_COLOR << std::endl; fine = false; } catch(const Gtk::BuilderError& ex) { std::cerr << BEGIN_RED << "BuilderError: " << ex.what() << END_COLOR << std::endl; fine = false; } if (fine) { refBuilder->get_widget("dialog_timing", this->dialog); refBuilder->get_widget("button_accept", this->button_accept); refBuilder->get_widget("button_cancel", this->button_cancel); refBuilder->get_widget("entry_time", this->entry_text); this->entry_text->set_text(Glib::ustring(this->gsubautomata->getTime())); this->button_accept->signal_clicked().connect(sigc::mem_fun(this, &TimerDialog::on_button_accept)); this->button_cancel->signal_clicked().connect(sigc::mem_fun(this, &TimerDialog::on_button_cancel)); this->dialog->add_events(Gdk::KEY_PRESS_MASK); this->dialog->signal_key_release_event().connect(sigc::mem_fun(this, &TimerDialog::on_key_released)); this->dialog->show_now(); } }
int Simulation::init() { // Obtain gtk's global lock m_Application = Gtk::Application::create("org.robotronik.simulation"); Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create(); try { refBuilder->add_from_file(SIMULATION_UI_FILE); refBuilder->get_widget("GlobalWindow", m_Window); m_Window->set_title("Simulation Robotronik"); refBuilder->get_widget("TableEventBox", TableEventBox); TableEventBox->set_events(Gdk::BUTTON_PRESS_MASK); TableEventBox->signal_motion_notify_event().connect( sigc::mem_fun(*this, &Simulation::on_plateau_movem)); TableEventBox->signal_button_press_event().connect( sigc::mem_fun(*this, &Simulation::on_plateau_click)); refBuilder->get_widget_derived("TableDrawingArea", plateau); Gsv::init(); m_communicationView.init(refBuilder); return 0; } catch(const Glib::FileError& ex) { std::cerr << "FileError: " <<ex.what() << std::endl; return 1; } catch(const Glib::MarkupError& ex) { std::cerr << "MarkupError: " <<ex.what() << std::endl; return 1; }catch(const Gtk::BuilderError& ex) { std::cerr << "BuilderError: "<<ex.what() << std::endl; return 1; } }
Gtk::Window* create_window1(char *argv) { Gtk::Window * window1; //load the glade file and instiate tis widgets: Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create(); try { builder->add_from_file(argv); } catch(const Glib::FileError& ex) { std::cerr << "FileError: " << ex.what() << std::endl; return 0; } catch(const Gtk::BuilderError& ex) { std::cerr << "BuilderError: " << ex.what() << std::endl; return 0; } builder->get_widget("window1",window1); return window1; }
int main (int argc, char *argv[]) { try { run_time rt (argc, argv, i18n); bpo::variables_map vm; std::string gui_file = "gtkmm/dialog.glade"; std::string rsc_file = "gtkmm/dialog.rc"; bpo::options_description opts (_("Utility options")); opts .add_options () ("layout" , bpo::value<std::string>(&gui_file), _("use an alternative GUI layout definition file")) ("resource", bpo::value<std::string>(&rsc_file), _("use an alternative GUI resource file")) ; if (rt.count ("help")) { std::cout << "\n" << opts << "\n"; return EXIT_SUCCESS; } if (rt.count ("version")) { std::cout << rt.version (); return EXIT_SUCCESS; } bpo::store (bpo::parse_command_line (argc, argv, opts), vm); bpo::notify (vm); Gtk::Main kit (argc, argv); Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create (); try { run_time rt; Gtk::RC::add_default_file (rt.data_file (run_time::pkg, rsc_file)); builder->add_from_file (rt.data_file (run_time::pkg, gui_file)); } catch (const Glib::Error& e) { std::cerr << e.what () << std::endl; return EXIT_FAILURE; } utsushi::gtkmm::dialog *window = 0; builder->get_widget_derived ("scanning-dialog", window); if (window) { Glib::add_exception_handler (&catch_and_return_to_GUI_thread); kit.run (*window); delete window; } } catch (std::exception& e) { std::cerr << e.what () << "\n"; return EXIT_FAILURE; } catch (...) { return EXIT_FAILURE; } return EXIT_SUCCESS; }
int main(int argc, char **argv) { //Objektet der kører alle GUI vinduer Gtk::Main kit (argc,argv); //Et objekt der bruges til at hente referencer til objekter i GUI-vinduet Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create(); try { //Henter al dataen fra .glade filen med definitioner på vinduet. Tilsvarende en xml fil. builder->add_from_file(".\\Final.glade"); } catch( Glib::FileError e) { std::cout << e.what(); return 1; } catch (Gtk::BuilderError e) { std::cout << e.what(); return 1; } //Henter de to hovedevinduer //pDialog er login vinduet, og mainWindow er selve vinduet builder->get_widget("LogInDialog", pDialog); builder->get_widget("mainWindow", mainWindow); //Hvis der er data i pDialog if(pDialog) { //Log in knap Gtk::Button *pButton = 0; //Henter data i pointers til login knappen, de to tekst elementer og den radioknap der vælger server builder->get_widget("LogIn",pButton); builder->get_widget("usrText", uName); builder->get_widget("pswText",pWord); builder->get_widget("connSwitch",connSwitch); //Sætter radioknappen til falsk connSwitch->set_active(false); if(pButton) { //Binder et signal (event handler) til en funktion. //Her er det det signal at login knappen bliver aktiveret, som aktiverer login funktionen pButton->signal_clicked().connect(sigc::ptr_fun(&onClick)); } //Åbner loginvinduet. Koden fortsætter først i main funktionen når vinduet bliver lukket eller skjult. kit.run(*pDialog); //Alt herunder køres først når login vinduet er lukket } //Tjekker om vores hjælpeobjekt er forbundet, og om der er data i pointeren til mainWindow if(connection1.Connected() && mainWindow) { builder->get_widget("weekChooser", box); //Fylder data ind i programmet første gang fillText(builder); if(box) { //Her et signal om at ugevægleren er ændret der bliver bundet til en funktion box->signal_changed().connect(sigc::bind<Glib::RefPtr<Gtk::Builder>>(sigc::ptr_fun(fillText), builder)); } //Åbner mainWindow. kit.run(*mainWindow); //Koden forsætter herefter når mainWindow bliver lukket. } return 0; }
int main(int argc, char * argv[]) { bool bShowVersion = false; Glib::OptionGroup::vecustrings listRemaining; #ifdef ENABLE_NLS setlocale(LC_ALL, ""); bindtextdomain("gvbam", LOCALEDIR); textdomain("gvbam"); #endif // ENABLE_NLS Glib::set_application_name(_("VBA-M")); Gtk::Main oKit(argc, argv); #ifdef USE_OPENGL Gtk::GL::init(argc, argv); #endif // USE_OPENGL Glib::OptionContext oContext; Glib::OptionGroup oGroup("main_group", _("Main VBA-M options")); Glib::OptionEntry oVersion; oVersion.set_long_name("version"); oVersion.set_short_name('v'); oVersion.set_description(_("Output version information.")); oGroup.add_entry(oVersion, bShowVersion); Glib::OptionEntry oFileName; oFileName.set_long_name(G_OPTION_REMAINING); oFileName.set_description(G_OPTION_REMAINING); oGroup.add_entry(oFileName, listRemaining); oContext.set_main_group(oGroup); try { oContext.parse(argc, argv); } catch (const Glib::Error& e) { Gtk::MessageDialog oDialog(e.what(), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK); oDialog.run(); return 1; } if (bShowVersion) { g_print(_("VisualBoyAdvance version %s [GTK+]\n"), VERSION); exit(0); } Gtk::Window::set_default_icon_name("vbam"); std::string sGtkBuilderFile = VBA::Window::sGetUiFilePath("vbam.ui"); Glib::RefPtr<Gtk::Builder> poXml; try { poXml = Gtk::Builder::create(); poXml->add_from_file(sGtkBuilderFile, "accelgroup1"); poXml->add_from_file(sGtkBuilderFile, "MainWindow"); } catch (const Gtk::BuilderError & e) { Gtk::MessageDialog oDialog(e.what(), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK); oDialog.run(); return 1; } VBA::Window * poWindow = NULL; poXml->get_widget_derived<VBA::Window>("MainWindow", poWindow); if (listRemaining.size() == 1) { // Display the window before loading the file poWindow->show(); while (Gtk::Main::events_pending()) { Gtk::Main::iteration(); } poWindow->bLoadROM(listRemaining[0]); } Gtk::Main::run(*poWindow); delete poWindow; return 0; }
int main (int argc, char *argv[]) { bindtextdomain(PACKAGE, Tools::getDirPath("locale").c_str()); bind_textdomain_codeset(PACKAGE, CODEC); textdomain(PACKAGE); #ifndef IS_GTK_2 Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.alsavolume"); Glib::ustring slider_ui_ = Tools::getResPath("gladefiles/SliderFrame.glade"); Glib::ustring settings_ui_ = Tools::getResPath("gladefiles/SettingsFrame.glade"); #else Gtk::Main app(argc, argv); Glib::ustring slider_ui_ = Tools::getResPath("gladefiles/SliderFrame_2.glade"); Glib::ustring settings_ui_ = Tools::getResPath("gladefiles/SettingsFrame_2.glade"); #endif if (slider_ui_.empty()) { std::cerr << "No SliderFrame.glade file found" << std::endl; return 1; } if (settings_ui_.empty()) { std::cerr << "No SettingsFrame.glade file found" << std::endl; return 1; } Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create(); try { refBuilder->add_from_file(slider_ui_); refBuilder->add_from_file(settings_ui_); } catch(const Gtk::BuilderError& ex) { std::cerr << "BuilderError::main.cpp::62 " << ex.what() << std::endl; return 1; } catch(const Glib::MarkupError& ex) { std::cerr << "MarkupError::main.cpp::62 " << ex.what() << std::endl; return 1; } catch(const Glib::FileError& ex) { std::cerr << "FileError::main.cpp::62 " << ex.what() << std::endl; return 1; } Core::Ptr core(new Core(refBuilder)); #ifndef IS_GTK_2 app->hold(); #endif SliderWindow *sliderWindow = 0; refBuilder->get_widget_derived("volumeFrame", sliderWindow); TrayIcon::Ptr trayIcon(new TrayIcon(core->getVolumeValue(), core->getSoundCardName(), core->getActiveMixer(), core->getMuted())); if (trayIcon && sliderWindow) { sliderWindow->setVolumeValue(core->getVolumeValue()); core->signal_value_changed().connect(sigc::mem_fun(*trayIcon, &TrayIcon::on_signal_volume_changed)); core->signal_mixer_muted().connect(sigc::mem_fun(*trayIcon, &TrayIcon::setMuted)); core->signal_volume_changed().connect(sigc::mem_fun(*sliderWindow, &SliderWindow::setVolumeValue)); sliderWindow->signal_volume_changed().connect(sigc::mem_fun(*core, &Core::onVolumeSlider)); trayIcon->signal_ask_dialog().connect(sigc::mem_fun(*core, &Core::runAboutDialog)); trayIcon->signal_ask_settings().connect(sigc::mem_fun(*core, &Core::runSettings)); trayIcon->signal_on_restore().connect(sigc::mem_fun(*sliderWindow, &SliderWindow::setWindowPosition)); trayIcon->signal_save_settings().connect(sigc::mem_fun(*core, &Core::saveSettings)); trayIcon->signal_on_mute().connect(sigc::mem_fun(*core, &Core::soundMuted)); trayIcon->signal_value_changed().connect(sigc::mem_fun(*core, &Core::onTrayIconScroll)); sliderWindow->set_visible(false); #ifndef IS_GTK_2 return app->run(); #else Gtk::Main::run(); #endif } delete sliderWindow; return 0; }
/* ================================== main ================================== */ int main(int argc, char** argv) { //This allows the creation and running of threads. Glib::thread_init(); // This is required for GTK to work. It must be the first GTK object // created and may not be global. Gtk::Main gtkmain(argc, argv); //This will extract widgets from the glade file when directed. const Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create(); try { builder->add_from_file(findgladepath(argv[0])); } catch (const Glib::FileError& ex) { std::cerr << "FileError: " << ex.what() << std::endl; return 1; } catch (const Glib::MarkupError& ex) { std::cerr << "MarkupError: " << ex.what() << std::endl; return 1; } catch (const Gtk::BuilderError& ex) { std::cerr << "BuilderError: " << ex.what() << std::endl; return 1; } Gtk::GL::init(argc, argv); Glib::RefPtr<Gdk::GL::Config> glconfig; glconfig = Gdk::GL::Config::create( Gdk::GL::MODE_RGB | Gdk::GL::MODE_DEPTH | Gdk::GL::MODE_DOUBLE); if (glconfig == 0) { glconfig = Gdk::GL::Config::create( Gdk::GL::MODE_RGB | Gdk::GL::MODE_DEPTH); if (glconfig == 0) { cout << "Cannot intialise OpenGL. Exiting." << endl; std::exit(1); } } //How many points in each bucket, maximum. int bucketlimit = 65536; // Label displaying the distance along the ruler, in all dimensions etc. // for the overview. Also other text output about the data and fences, // profiles etc. is put here. Gtk::Label *rulerlabelover = NULL; builder->get_widget("rulerlabelover", rulerlabelover); //The 2d overview. TwoDeeOverview *tdo = new TwoDeeOverview(glconfig, bucketlimit, rulerlabelover); // Label displaying the distance along the ruler, in all dimensions // etc. for the profile. Gtk::Label *rulerlabel = NULL; builder->get_widget("rulerlabel", rulerlabel); //The profile. Profile *prof = new Profile(glconfig, bucketlimit, rulerlabel); //This contains the widgets of the advanced options window. AdvancedOptionsWindow *aow = new AdvancedOptionsWindow(tdo, prof, builder); //This contains the widgets of the file saver window. FileSaver *fs = new FileSaver(tdo, prof, builder); // Contains the overview. It is used to simulate the 2d overview getting // focus without causing it to be redrawn every time. Gtk::EventBox *eventboxtdo = NULL; builder->get_widget("eventboxtdo", eventboxtdo); // Contains the profile. It is used to simulate the profile getting focus // without causing it to be redrawn every time. Gtk::EventBox *eventboxprof = NULL; builder->get_widget("eventboxprof", eventboxprof); Gtk::Window *overviewwindow = NULL; builder->get_widget("overviewwindow", overviewwindow); Gtk::Window *profilewindow = NULL; builder->get_widget("profilewindow", profilewindow); //This contains the widgets of the profile window. ProfileWindow *profwin = new ProfileWindow(prof, tdo, profilewindow, overviewwindow, eventboxprof, builder, aow); //This contains the widgets of the 2D overview window. TwoDeeOverviewWindow *tdow = new TwoDeeOverviewWindow(tdo, aow, fs, overviewwindow, profilewindow, builder, eventboxtdo, profwin); //This contains the widgets of advanced loading options window AdvancedLoadDialog* ald = new AdvancedLoadDialog(builder); //This contains the widgets of the file opener window. FileOpener *fo = new FileOpener(tdo, prof, builder, aow, fs, bucketlimit, eventboxtdo, eventboxprof, tdow, ald); gdk_threads_enter(); gtkmain.run(*overviewwindow); gdk_threads_leave(); tdo->stopDrawingThread(); prof->stopDrawingThread(); delete tdow; delete profwin; delete fo; delete fs; delete aow; delete eventboxtdo; delete eventboxprof; delete rulerlabelover; delete overviewwindow; delete profilewindow; delete ald; if (tdo != NULL) delete tdo; if (prof != NULL) delete prof; return 0; }