Exemple #1
0
	void CamControl::Show()
	{
        if ( m_pCamera == NULL )
        {
            return;
        }     

        if ( bFirst )
        {
            m_pWindow->set_position( Gtk::WIN_POS_CENTER );
            m_pWindow->get_position( m_xPos, m_yPos );
            bFirst = false;
        }

        m_pWindow->move( m_xPos, m_yPos );
			        
        Gtk::Main* kit = NULL;
        kit = Gtk::Main::instance();   

        // If the level is 0, then it means there is no GTK loop currently
        // running. This is often seen in applications that are not
        // written in GTKmm (e.g. MFC). 
        if ( kit->level() == 0 )
        {
            // Start a loop since none are present.
            kit->run( *m_pWindow );
        }
        else
        {
            // There already is a loop, just show the window
            m_pWindow->show();
        }        
	}
Exemple #2
0
int main(int argc, char *argv[]) {
    Gtk::Main kit (argc, argv);

    Bras *bras;

    try {
        bras = Bras::get();
    } catch (std::exception& error) {
        Gtk::MessageDialog msg(error.what(), false,
                               Gtk::MESSAGE_ERROR,
                               Gtk::BUTTONS_NONE,
                               true);

        msg.add_button("Start brasd", Gtk::RESPONSE_RESTART);
        msg.add_button(GTK_STOCK_CLOSE, Gtk::RESPONSE_CLOSE)->grab_focus();

        /* start brasd, and then restart bras-client */
        if(msg.run() == Gtk::RESPONSE_RESTART) {
            /* this is the easy dirty way */
            pclose(popen("gksu service brasd start", "r"));
            execlp("bras-client", "bras-client", NULL);
        }

        return 0; /* We have not enter main loop, so don't use Gtk::Main::Quit */
    }

    bras->signal_state_changed.connect(sigc::ptr_fun(on_bras_state_change));

    kit.run();
}
Exemple #3
0
int main () {
  Gtk::Main kit;

  GLWindow window;
  window.show_all ();

  kit.run (window);
}
Exemple #4
0
int main(int /*argc*/, char** /*argv*/)
{
    Gtk::Main* pKit = Gtk::Main::instance();
    if ( pKit == NULL )
    {
        pKit = new Gtk::Main( 0, NULL );
    }

    // Initialize the thread system
    if( !Glib::thread_supported() ) 
    {
        Glib::thread_init();
    }  

    // Display the camera selection dialog
    PGRGuid guid[64];
    unsigned int size = 64;
    bool ok = GetCameras( &guid[0], &size );
    if ( ok != true || size <= 0 )
    {
        return -1;
    }      

    // Create the individual windows
    FlycapWindow* windows = new FlycapWindow[size];
    for ( unsigned int i = 0; i < size; i++ )
    {
        bool ret = windows[i].Run( guid[i] );
        if ( ret != true )
        {
            for ( int j=0; j < i; j++)
            {
                // Clean up all windows that are already created
                windows[j].Cleanup();
            }

            delete [] windows;
            return -1;
        }
    }

    // Start the main Gtk event loop
    pKit->run();

    // This point is reached when the last window alive kills the Gtk::Main loop

    // Perform cleanup on all the windows
    for ( unsigned int i = 0; i < size; i++ )
    {
        windows[i].Cleanup();
    }    

    delete [] windows;

    return 0;
}
bool GTKWindow::pump_events()
{
    Gtk::Main *kit = Gtk::Main::instance();
    if (kit->events_pending())
    {
        kit->iteration(false);
        return true;
    }
    return false;
}
Exemple #6
0
int main(int argc, char **argv){

    Gtk::Main     kit (argc, argv);
    Gtk::Window   win;
    GObjTestTile  pl;

    SimpleViewer viewer(&pl);

    win.add(viewer);
    win.set_default_size(640,480);
    win.show_all();

    kit.run(win);
}
Exemple #7
0
int main(int argc, char **argv){

    Gtk::Main     kit (argc, argv);
    Gtk::Window   win;
    GObjTestGrid  pl(150000);

    DThreadViewer viewer(&pl);

    win.add(viewer);
    win.set_default_size(640,480);
    win.show_all();

    kit.run(win);
}
Exemple #8
0
    virtual bool configure(ResourceFinder &rf)
    {
        Time::turboBoost();

        //check if the yarp networ is running
        if (yarp.checkNetwork()==false)
        {
            return false;
        }

        moduleName = rf.check("name", Value(1), "module name (string)").asString();
        setName(moduleName.c_str());
        
        period = rf.check("period", Value(5000), "update period (int)").asInt();

        string pname  = "/" + moduleName + ":o";
        monitorOutput.open(pname.c_str());
         
        picBlocks = rf.findFile(rf.check("pic_blocks", Value(1), "module name (string)").asString());
        picBackground = rf.findFile(rf.check("pic_background", Value(1), "module name (string)").asString());
        picNumbers = rf.findFile(rf.check("pic_numbers", Value(1), "module name (string)").asString());

        graphics = new GraphicsManager(picBackground.c_str(),picBlocks.c_str(),picNumbers.c_str());
        m_timer = Glib::signal_timeout().connect(sigc::mem_fun(*this, &CtrlModule::on_timeout), period);
        on_timeout();

        //start GTK loop
        gtk_main->run(*graphics);

        return true;
    }
Exemple #9
0
int main (int argc, char **argv)
{
    setlocale (LC_ALL, "");
    bindtextdomain (PACKAGE, LOCALE_DIR);
    textdomain (PACKAGE);

    Glib::ustring tmpdir;
    Gtk::Main kit (argc, argv);

    tmpdir = Pixasso::create_tmpdir ();
    chdir (tmpdir.c_str ());

    Pixasso::MainWindow window;
    kit.run (window);

    Pixasso::remove_dir (tmpdir);
}
Exemple #10
0
 virtual bool interruptModule()
 {
     gtk_main->quit();
     monitorOutput.interrupt();
     if (graphics) delete graphics;
     delete gtk_main;
     close();
     return true;
 }
Exemple #11
0
int main(int argc, char **argv){

    Gtk::Main     kit (argc, argv);
    Gtk::Window   win;
    GObjTestTile  p1;

    SimpleViewer viewer(&p1);
    Rubber rubber(&viewer);

    iPoint p(20,20);
    rubber.add_src_sq(p, 3);
    rubber.add_dst_sq(3);
    rubber.add_rect(p);
    rubber.add_line(p);

    win.add(viewer);
    win.set_default_size(640,480);
    win.show_all();

    kit.run(win);
}
int main(int argc , char *argv[])
{
	std::cout << "widget test: WaveView dialog" << std::endl;
	Gtk::Main kit (argc,argv);
	Gtk::Window window;
	Gtk::Button button("Quit");
	Gtk::HBox hbox;
	MidiEditor waveview;
	
	// bind button to quit value of kit, by providing pointer to kit.
	button.signal_clicked().connect( sigc::bind(sigc::ptr_fun ( quit ), &kit));
	
	hbox.add(waveview);
	hbox.add(button);
	
	window.add(hbox);
	window.show_all();
	kit.run(window);
	
	return 0;
	
}
Exemple #13
0
void startup(Glib::RefPtr<Gtk::Application> app) {
	///To be run at startup
	
	GtkSettings *settings;
	settings = gtk_settings_get_default();
	g_object_set (G_OBJECT (settings), "gtk-application-prefer-dark-theme", FALSE, NULL);
	
	Gtk::Main kit;
	
	builder = Gtk::Builder::create_from_file(DATADIR "/main.glade");
	Gtk::Window *window = 0;
	builder->get_widget("window1", window);
	window->set_wmclass("org.gtkmm.examples.application", name);
	window->maximize();
	
	Gtk::TreeView *listview = 0;
	builder->get_widget("treeview1", listview);
	
	Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
	m_refTreeModel = Gtk::ListStore::create(m_columns);
	listview->set_model(m_refTreeModel);
	listview->set_search_column(1);
	
	Glib::RefPtr<Gtk::TreeSelection> list_selection = listview->get_selection();
	listview->signal_row_activated().connect(sigc::bind<Glib::RefPtr<Gtk::TreeModel> >(sigc::ptr_fun(&on_button_clicked), listview->get_model()));
	
	Json::Value json = readFile(getRemoteFile("https://api.4chan.org/boards.json"));
	Json::Value boards = json["boards"];
	for(int i=0;i<boards.size();++i) {
		Gtk::TreeModel::Row row = *(m_refTreeModel->append());
		row[m_columns.name] = "/"+boards[i]["board"].asString()+"/";
		row[m_columns.longname] = boards[i]["title"].asString();
	}
	listview->set_rules_hint(true);
	
	Gtk::Menu *mainmenu = 0;
	builder->get_widget("menu1", mainmenu);
	Gtk::MenuToolButton *toolbut = 0;
	builder->get_widget("toolbutton2", toolbut);
	toolbut->set_menu(*mainmenu);
	
	Gtk::MenuItem *item1 = 0;
	builder->get_widget("menuitem1", item1);
	item1->signal_activate().connect(sigc::ptr_fun(&nameSettingsDialog));
	
	Gtk::CheckMenuItem *hideimages = 0;
	builder->get_widget("menuitem2", hideimages);
	hideimages->signal_toggled().connect(sigc::ptr_fun(&on_hide_toggled));
	
	Gtk::MenuItem *item3 = 0;
	builder->get_widget("menuitem3", item3);
	item3->signal_activate().connect(sigc::ptr_fun(&open_thread_in_browser));
	
	Gtk::MenuItem *d_image = 0;
	builder->get_widget("menuitem5", d_image);
	d_image->signal_activate().connect(sigc::ptr_fun(&saveImageAs));
	
	Gtk::ToolButton *post_but;
	builder->get_widget("toolbutton8", post_but);
	post_but->signal_clicked().connect(sigc::ptr_fun(&on_post_button_toggled));
	
	Gtk::Button *post_but2 = 0;
	builder->get_widget("button4", post_but2);
	post_but2->signal_clicked().connect(sigc::ptr_fun(&on_post_clicked));
	
	kit.run(*window);
}
Exemple #14
0
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;
}
Exemple #15
0
void ChessView::run(Gtk::Main & app)
{
	InitializeTimer();
	on_NewGame();
	app.run(*gui);
}
Exemple #16
0
int main(int argc, char **argv)
{
   LogWrapperType logwrapper(new btg::core::logger::logWrapper);
 
   btg::core::crashLog::init();

   commandLineArgumentHandler* cla = new commandLineArgumentHandler(GPD->sGUI_CONFIG());

   cla->setup();

   // Parse command line arguments.
   if (!cla->parse(argc, argv))
      {
         delete cla;
         cla    = 0;

         projectDefaults::killInstance();

         return BTG_ERROR_EXIT;
      }

   // Before doing anything else, check if the user wants to get the
   // syntax of the configuration file.
   if (cla->listConfigFileSyntax())
      {
         clientConfiguration non_existing(logwrapper, "non_existing");

         std::cout << non_existing.getSyntax() << std::endl;

         delete cla;
         cla = 0;

         projectDefaults::killInstance();

         return BTG_NORMAL_EXIT;
      }

   bool verboseFlag = cla->beVerbose();

   Gtk::Main* initMain = new Gtk::Main(&argc, &argv);

   BTG_NOTICE(logwrapper, "Creating the init window.");
   initWindow* iw = new initWindow();
   iw->show();

   // Update init dialog.
   iw->updateProgress(initWindow::IEV_START);

   iw->updateProgress(initWindow::IEV_RCONF);

   // Open the configuration file:
   std::string config_filename = GPD->sCLI_CONFIG();

   if (cla->configFileSet())
      {
         config_filename = cla->configFile();
      }

   std::string errorString;
   if (!btg::core::os::fileOperation::check(config_filename, errorString, false))
      {
         BTG_FATAL_ERROR(logwrapper,
                         GPD->sGUI_CLIENT(), "Could not open file '" << config_filename << "'");

         return BTG_ERROR_EXIT;
      }

   // Open the configuration file:
   clientConfiguration* config = new clientConfiguration(logwrapper, config_filename);

   bool const gotConfig = config->read();

   bool neverAskFlag = config->getNeverAskQuestions();

   clientDynConfig cliDynConf(logwrapper, GPD->sCLI_DYNCONFIG());
   lastFiles* lastfiles = new lastFiles(logwrapper, cliDynConf);

   // Update init dialog.
   iw->updateProgress(initWindow::IEV_RCONF_DONE);

   // Update init dialog.
   // iw->updateProgress(initWindow::IEV_CLA);

   if (!gotConfig)
      {
         BTG_FATAL_ERROR(logwrapper,
                         GPD->sGUI_CLIENT(), "Could not read the config file, '" << GPD->sGUI_CONFIG() << "'. Create one.");
         delete config;
         config = 0;

         delete lastfiles;
         lastfiles = 0;

         delete cla;
         cla    = 0;

         delete iw;
         iw = 0;

         delete initMain;
         initMain = 0;

         projectDefaults::killInstance();

         return BTG_ERROR_EXIT;
      }

   // Update init dialog.
   iw->updateProgress(initWindow::IEV_CLA_DONE);

   // Update init dialog.
   iw->updateProgress(initWindow::IEV_TRANSP);

   // Create a transport to the daemon:
   btg::core::externalization::Externalization* externalization = 0;
   messageTransport* transport                                  = 0;

   transportHelper* transporthelper = new transportHelper(logwrapper,
                                                          GPD->sGUI_CLIENT(),
                                                          config,
                                                          cla);

   if (!transporthelper->initTransport(externalization, transport))
      {
         errorDialog::showAndDie(transporthelper->getMessages());

         delete config;
         config = 0;

         delete lastfiles;
         lastfiles = 0;

         delete cla;
         cla    = 0;

         delete transport;
         transport = 0;

         delete externalization;
         externalization = 0;

         delete iw;
         iw = 0;

         delete initMain;
         initMain = 0;

         delete transporthelper;
         transporthelper = 0;

         projectDefaults::killInstance();

         return BTG_ERROR_EXIT;
      }

   delete transporthelper;
   transporthelper = 0;

   // Update init dialog.
   iw->updateProgress(initWindow::IEV_TRANSP_DONE);

   guiHandler* guihandler = new guiHandler(logwrapper,
                                           externalization,
                                           transport,
                                           config,
                                           lastfiles,
                                           verboseFlag,
                                           cla->automaticStart(),
                                           0 /* initially null */);

   std::string initialStatusMessage("");

   // Update init dialog.
   iw->updateProgress(initWindow::IEV_SETUP);

   // Create a helper to do the initial setup of this client.
   startupHelper* starthelper = new guiStartupHelper(logwrapper,
                                                     config,
                                                     cla,
                                                     transport,
                                                     guihandler);

   if (!starthelper->init())
      {
         errorDialog::showAndDie(starthelper->getMessages());
         BTG_FATAL_ERROR(logwrapper,
                         GPD->sGUI_CLIENT(), "Internal error: start up helper not initialized.");

         delete starthelper;
         starthelper = 0;

         delete guihandler;
         guihandler = 0;

         delete externalization;
         externalization = 0;

         delete cla;
         cla = 0;

         delete iw;
         iw = 0;

         delete initMain;
         initMain = 0;

         delete config;
         config = 0;

         delete lastfiles;
         lastfiles = 0;

         projectDefaults::killInstance();

         return BTG_ERROR_EXIT;
      }

   setDefaultLogLevel(logwrapper, cla->doDebug(), verboseFlag);

   // Initialize logging.
   if (starthelper->execute(startupHelper::op_log) != startupHelper::or_log_success)
      {
         BTG_FATAL_ERROR(logwrapper,
                         GPD->sCLI_CLIENT(), "Unable to initialize logging");

         delete starthelper;
         starthelper = 0;

         delete guihandler;
         guihandler = 0;

         delete externalization;
         externalization = 0;

         delete cla;
         cla = 0;

         delete iw;
         iw = 0;

         delete initMain;
         initMain = 0;

         delete config;
         config = 0;

         delete lastfiles;
         lastfiles = 0;

         projectDefaults::killInstance();

         return BTG_ERROR_EXIT;
      }

   if (config->authSet())
      {
         // Auth info is in the config.
         starthelper->setUser(config->getUserName());
         starthelper->setPasswordHash(config->getPasswordHash());
      }
   else
      {
         // Ask the user about which username and password to use.
         if (starthelper->execute(startupHelper::op_auth) != startupHelper::or_auth_success)
            {
               BTG_FATAL_ERROR(logwrapper,
                               GPD->sCLI_CLIENT(), "Unable to initialize logging");
               delete starthelper;
               starthelper = 0;

               delete guihandler;
               guihandler = 0;

               delete externalization;
               externalization = 0;

               delete cla;
               cla = 0;

               delete iw;
               iw = 0;

               delete initMain;
               initMain = 0;

               delete config;
               config = 0;

               delete lastfiles;
               lastfiles = 0;

               projectDefaults::killInstance();

               return BTG_ERROR_EXIT;
            }
      }

   /// Initialize the transport
   starthelper->execute(startupHelper::op_init);

   // Handle command line options:
   if (cla->doList())
      {
         if (starthelper->execute(startupHelper::op_list) == startupHelper::or_list_failture)
            {
               errorDialog::showAndDie(starthelper->getMessages());
            }

         // Clean up, before quitting.
         delete starthelper;
         starthelper = 0;

         delete guihandler;
         guihandler = 0;

         delete externalization;
         externalization = 0;

         delete cla;
         cla = 0;

         delete iw;
         iw = 0;

         delete initMain;
         initMain = 0;

         delete config;
         config = 0;

         delete lastfiles;
         lastfiles = 0;

         projectDefaults::killInstance();

         return BTG_NORMAL_EXIT;
      }
   else if (cla->doAttachFirst())
      {
         // Attach to the first available session.

         if (starthelper->execute(startupHelper::op_attach_first) == startupHelper::or_attach_first_failture)
            {
               errorDialog::showAndDie(starthelper->getMessages());
               BTG_FATAL_ERROR(logwrapper,
                               GPD->sGUI_CLIENT(), "Unable to attach to session");

               // Clean up, before quitting.
               delete starthelper;
               starthelper = 0;

               delete guihandler;
               guihandler = 0;

               delete cla;
               cla = 0;

               delete externalization;
               externalization = 0;

               delete iw;
               iw = 0;

               delete initMain;
               initMain = 0;

               delete config;
               config = 0;

               delete lastfiles;
               lastfiles = 0;

               projectDefaults::killInstance();

               return BTG_ERROR_EXIT;
            }

         initialStatusMessage = "Attached to session.";
      }
   else if (cla->doAttach())
      {
         // Attach to a certain session, either specified on the
         // command line or chosen by the user from a list.

         startupHelper::operationResult result = starthelper->execute(startupHelper::op_attach);

         if (result == startupHelper::or_attach_failture)
            {
               errorDialog::showAndDie(starthelper->getMessages());
               BTG_FATAL_ERROR(logwrapper,
                               GPD->sGUI_CLIENT(), "Unable to attach to session");
            }
         
         if ((result == startupHelper::or_attach_failture) || 
             (result == startupHelper::or_attach_cancelled))
            {
               // Clean up, before quitting.
               delete starthelper;
               starthelper = 0;
	     
               delete guihandler;
               guihandler = 0;
	     
               delete externalization;
               externalization = 0;
	     
               delete cla;
               cla = 0;
	     
               delete iw;
               iw = 0;
	     
               delete initMain;
               initMain = 0;
	     
               delete config;
               config = 0;
	     
               delete lastfiles;
               lastfiles = 0;
	     
               projectDefaults::killInstance();

               return BTG_ERROR_EXIT;
            }

         initialStatusMessage = "Attached to session.";

      } // Attach to as session.

   bool executeSetup        = false;
   bool attachToSession     = false;
   t_long sessionToAttachTo = Command::INVALID_SESSION;

   if ((!cla->doAttach()) && (!cla->doAttachFirst()))
      {
         // Not attaching to a session. Show a dialog that lets one
         // select which session to use or to create a new one.

         // Get a list of sessions.
         guihandler->reqGetActiveSessions();
         
         t_longList sessionlist = guihandler->getSessionList();
         t_strList sessionsIDs = guihandler->getSessionNames();

         sessionDialog* sd = new sessionDialog(sessionlist, sessionsIDs);
         sd->run();

         switch (sd->getResult())
            {
            case sessionDialog::QUIT:
               {
                  delete sd;
                  sd = 0;

                  // Clean up, before quitting.
                  delete starthelper;
                  starthelper = 0;
                  
                  delete guihandler;
                  guihandler = 0;
                  
                  delete externalization;
                  externalization = 0;
                  
                  delete cla;
                  cla = 0;
	     
                  delete iw;
                  iw = 0;
                  
                  delete initMain;
                  initMain = 0;
                  
                  delete config;
                  config = 0;
                  
                  delete lastfiles;
                  lastfiles = 0;
                  
                  projectDefaults::killInstance();

                  return BTG_ERROR_EXIT;
                  break;
               }
            case sessionDialog::NEW_SESSION:
               {
                  executeSetup    = true;
                  attachToSession = false;
                  // Create a new session.
                  break;
               }
            case sessionDialog::SELECTED:
               {
                  // A session was selected.
                  executeSetup    = false;
                  attachToSession = true;
                  sd->getSelectedSession(sessionToAttachTo);
                  break;
               }
            }

         delete sd;
         sd = 0;
      }
   
   // Only execute setup if we are not attaching to an existing session.
   if (executeSetup)
      {
         if (starthelper->execute(startupHelper::op_setup) == startupHelper::or_setup_failture)
            {
               errorDialog::showAndDie(starthelper->getMessages());

               // Clean up, before quitting.
               delete starthelper;
               starthelper = 0;

               delete guihandler;
               guihandler = 0;

               delete externalization;
               externalization = 0;

               delete cla;
               cla = 0;

               delete iw;
               iw = 0;

               delete initMain;
               initMain = 0;

               delete config;
               config = 0;

               delete lastfiles;
               lastfiles = 0;

               projectDefaults::killInstance();

               return BTG_ERROR_EXIT;
            }

         initialStatusMessage = "Established session.";
      }

   if (attachToSession)
      {
         std::string errorMessage;
         guihandler->reqSetupAttach(sessionToAttachTo);

         if (!guihandler->isAttachDone())
            {
               errorDialog::showAndDie("Unable to attach to session");
               BTG_FATAL_ERROR(logwrapper,
                               GPD->sGUI_CLIENT(), "Unable to attach to session");

               // Clean up, before quitting.
               delete starthelper;
               starthelper = 0;

               delete guihandler;
               guihandler = 0;

               delete externalization;
               externalization = 0;

               delete cla;
               cla = 0;

               delete iw;
               iw = 0;

               delete initMain;
               initMain = 0;

               delete config;
               config = 0;

               delete lastfiles;
               lastfiles = 0;

               projectDefaults::killInstance();

               return BTG_ERROR_EXIT;
            }
      }

   // If the user requested to open any files, do it.
   if (cla->inputFilenamesPresent())
      {
         t_strList filelist = cla->getInputFilenames();
         t_strListCI iter;
         for (iter = filelist.begin(); iter != filelist.end(); iter++)
            {
               guihandler->reqCreate(*iter);
            }
      }

   // Done using arguments.
   delete cla;
   cla = 0;

   // Done using the start up helper.
   delete starthelper;
   starthelper = 0;

   // Update init dialog.
   iw->updateProgress(initWindow::IEV_SETUP_DONE);

   // Update init dialog.
   iw->updateProgress(initWindow::IEV_END);

   t_long session = guihandler->session();
   std::string str_session = btg::core::convertToString<t_long>(session);

   // Get some info about the current session, so it can be displayed
   // to the user.
   guihandler->reqSessionInfo();
   
   if (guihandler->dht())
      {
         str_session += " D";
      }

   if (guihandler->encryption())
      {
         str_session += " E";
      }

   // Start a thread that takes care of communicating with the daemon.
   handlerThread* handlerthr = new handlerThread(logwrapper,
                                                 verboseFlag, 
                                                 guihandler);

   mainWindow* mainWindow = new class mainWindow(logwrapper,
                                                 str_session, 
                                                 verboseFlag, 
                                                 neverAskFlag,
                                                 handlerthr,
                                                 cliDynConf
                                                 );

   BTG_NOTICE(logwrapper, initialStatusMessage);

   BTG_NOTICE(logwrapper, "Deleting the init window.");

   iw->hide();
   delete iw;
   iw = 0;

   initMain->run(*mainWindow);

   delete mainWindow;
   mainWindow = 0;

   delete handlerthr;
   handlerthr = 0;

   // By deleting the gui handler, the transport used is also deleted.
   delete guihandler;
   guihandler = 0;

   delete externalization;
   externalization = 0;

   delete initMain;
   initMain = 0;

   if (config->modified())
      {
         config->write();
      }

   delete config;
   config = 0;

   delete lastfiles;
   lastfiles = 0;

   projectDefaults::killInstance();

   return BTG_NORMAL_EXIT;
}
Exemple #17
0
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;
}