Exemplo n.º 1
0
bool
GtkAReViWidget::getWidgetString(const StlString &propName,StlString &propValueOut)
{
  GtkWidget *widget=glade_xml_get_widget(_xmlObject,propName.c_str());
  if (!widget)
  {
    cerr << "[getPropertyString] property '" << propName << "' no exist" << endl;
    return false;
  }

  if (GTK_IS_ENTRY(widget))
    propValueOut=/*strFromUTF8*/(gtk_entry_get_text(GTK_ENTRY(widget)));
  else if (GTK_IS_TOGGLE_BUTTON(widget))
  {
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) propValueOut="true";
    else propValueOut="false";
  }
  else if (GTK_IS_TEXT_VIEW(widget))
  {
    GtkTextBuffer* buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
    GtkTextIter start, end;
    gtk_text_buffer_get_bounds(buffer,&start,&end);
    propValueOut=/*strFromUTF8*/(gtk_text_buffer_get_text(buffer,&start,&end,true));
  }
  else return false;

  return true;
}
Exemplo n.º 2
0
 URLSound3D::URLSound3D(StlString const &url) :
     _gain(0),
     _attenuated(false)
 {
     buffer = LoadSound(url.c_str());
     alGenSources(1, &source);
     alSourcei(source, AL_BUFFER, buffer);
 }
Exemplo n.º 3
0
bool IsValidFolder(StlString folder_name)
{
	bool ret_val;
	TCHAR curr_dir[MAX_PATH];
	GetCurrentDirectory(MAX_PATH, curr_dir);
	ret_val = (FALSE != SetCurrentDirectory(folder_name.c_str()));
	SetCurrentDirectory(curr_dir);
	return ret_val;	
}
Exemplo n.º 4
0
//-------- Construction / Destruction ----------------------------------------
GtkAReViWidget::GtkAReViWidget(ArCW & arCW,
                               const StlString &fileName,
                               const StlString &mainWidget) // Protected
: ArObject(arCW),
  _xmlObject(glade_xml_new(fileName.c_str(),  mainWidget.c_str(), NULL)),
  _wndMain(NULL),
  _hideOnDestroy(false),
  _dockDst(),
  _dockDstWidget(""),
  _wndDockSrc(NULL),
  _docked(false) {
  if(_xmlObject) {
    _wndMain=GTK_WIDGET(glade_xml_get_widget(_xmlObject,mainWidget.c_str()));
    if (!_wndMain)
      setErrorMessage("Can't find main widget " + mainWidget);
    else
      g_signal_connect ((gpointer)_wndMain,"delete_event",G_CALLBACK(_onWidgetCloseCB),this);
  }
  else
    thisRef().destroy();
}
Exemplo n.º 5
0
static bool IsPartOfMultipartArchive(const StlString& fname)
{
	StlString fname_nopath;
	size_t last_slash_pos = fname.find_last_of(_T('\\'));
	if (fname.size() == last_slash_pos)
	{
		LOG(("[IsPartOfMultipartArchive] ERROR: wrong file name: %S\n", 
			(wstring(fname.begin(), fname.end())).c_str()));
		return false;
	}
	fname_nopath = (StlString::npos == last_slash_pos) ? fname : fname.substr(last_slash_pos + 1);

	boost::tregex re(_T("(.*)(\\.part)([0-9]+)(\\.rar)"), 
		boost::tregex::perl|boost::tregex::icase); 


	bool ret_val = false;

	if (boost::regex_match(fname_nopath, re))
	{
		size_t pos;
		pos = fname_nopath.find_last_of(_T('.'));
		if (StlString::npos != pos)
		{
			StlString tmp = fname_nopath.substr(0, pos);
			pos = tmp.find_last_of(_T(".part"));
			if (StlString::npos != pos && pos < tmp.size() - 1)
			{
				tmp = tmp.substr(pos + 1);
				int part_num = _ttoi(tmp.c_str());
				
				ret_val = (part_num != 1);
			}
		}
	}

	return ret_val;
}
Exemplo n.º 6
0
bool
GtkAReViWidget::setWidgetString(const StlString &propName,const StlString &propValue)
{
  GtkWidget *widget=glade_xml_get_widget(_xmlObject,propName.c_str());
  if (!widget)
  {
    cerr << "[setPropertyString] property '" << propName << "' no exist" << endl;
    return false;
  }
  if (GTK_IS_ENTRY(widget))
    gtk_entry_set_text(GTK_ENTRY(widget),/*strToUTF8*/(propValue).c_str());
  else if (GTK_IS_TOGGLE_BUTTON(widget))
  {
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),propValue=="true");
  }
  else if (GTK_IS_TEXT_VIEW(widget))
  {
    GtkTextBuffer* buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
    gtk_text_buffer_set_text(buffer,/*strToUTF8*/(propValue).c_str(),-1);
  }
  else return false;

  return true;
}
Exemplo n.º 7
0
    Sound3DPlayer::Sound3DPlayer(StlVector<StlString> const * params)
    {
        //Sound3D::_initSuccess=false;
        StlString openArgs;
        if(params&&!params->empty())
        {
            for(unsigned int i = 0; i < params->size(); i++)
            {
                if(i) openArgs+=" ";
                openArgs += (*params)[i];
            }
            openArgs = "'( ( devices '( " + openArgs + " ) ) )";
            device = alcOpenDevice(openArgs.c_str());
        }

        if(!device)
        {
            device = alcOpenDevice(NULL);
            if(!device)
            {
                cerr << "ERROR: Sound3DPlayer init: unable to open sound3D device !!!" << endl;
                //return(false);
                return;
            }
        }

        globalContext = alcCreateContext(device, NULL);

        if(!globalContext)
        {
            alcCloseDevice(device);
            globalContext = NULL;
            cerr << "ERROR: Sound3DPlayer init: unable to create al context !!!" << endl;
            //return(false);
            return;
        }

        if(alcMakeContextCurrent(globalContext) == ALC_FALSE)
        {
            alcDestroyContext(globalContext);
            alcCloseDevice(device);
            cerr << "ERROR: Sound3DPlayer init: unable to make context current !!!" << endl;
            return;
        }

        if(!alcIsExtensionPresent(alcGetContextsDevice(alcGetCurrentContext()), "ALC_EXT_EFX"))
        {
            alcDestroyContext(globalContext);
            alcCloseDevice(device);
            cerr << "ERROR: Sound3DPlayer init: EFX not supported" << endl;
            return;
        }

#if defined(AL_SOFT_buffer_samples) && AL_SOFT_buffer_samples
        if(alIsExtensionPresent("AL_SOFT_buffer_samples"))
        {
            alIsBufferFormatSupportedSOFT = (LPALISBUFFERFORMATSUPPORTEDSOFT)alGetProcAddress("alIsBufferFormatSupportedSOFT");
            alBufferSamplesSOFT = (LPALBUFFERSAMPLESSOFT)alGetProcAddress("alBufferSamplesSOFT");
        }
#endif

        alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
        //alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED);

        cout << "Sound3DPlayer Opened \"" << alcGetString(device, ALC_DEVICE_SPECIFIER) << "\"" << endl;
#if 0
        cout << "AL_DOPPLER_FACTOR: " << alGetDouble(AL_DOPPLER_FACTOR) << endl;
        cout << "AL_SPEED_OF_SOUND: " << alGetDouble(AL_SPEED_OF_SOUND) << endl;
        cout << "AL_DISTANCE_MODEL: " << alGetInteger(AL_DISTANCE_MODEL) << endl;
#endif
    }