示例#1
0
/** get a string composed of elements separated by personnal separator, and return in vector
 *  each element
 */
int mini_parser(char separator, Glib::ustring str, std::vector<string>* vector )
{
	int res = - 1 ;
	vector->clear() ;
	guint last = 0 ;

	bool cut = false ;

	if (str!="") {
		for (guint i=0; i<str.size(); i++) {
			if ( str[i]==separator ) {
				cut = true ;
				vector->insert(vector->end(), str.substr(last,i-last) );
				last=i+1 ;
			}
		}
		if (cut)
			vector->insert(vector->end(), str.substr(last,str.size()-1) );
		else
			vector->insert(vector->end(), str.substr(last,str.size()) );
		res = 1 ;
	}
	else {
		Log::err() << "mini_parser <information:> no string value" << std::endl ;
	}
	return res ;
}
示例#2
0
文件: Tools.cpp 项目: bgK/vba-ttb
bool bHasSuffix(const Glib::ustring & _rsString,
                const Glib::ustring & _rsSuffix,
                bool _bCaseSensitive)
{
	if (_rsSuffix.size() > _rsString.size())
	{
		return false;
	}

	Glib::ustring sEnd = _rsString.substr(_rsString.size() - _rsSuffix.size());

	if (_bCaseSensitive)
	{
		if (_rsSuffix == sEnd)
		{
			return true;
		}
	}
	else
	{
		if (_rsSuffix.lowercase() == sEnd.lowercase())
		{
			return true;
		}
	}

	return false;
}
示例#3
0
void XGPacketBuilder::on_data_change()
{
        if (updating_fields)
                return;
        
        pkt.data.clear();
        
        Glib::ustring str = tv_data.get_buffer()->get_text();
        
        if (hex_data.get_active())
        {
                for (int i = 0; i < str.size(); i++)
                {
                        int k, num;
                        uint8_t b;
                        
                        if (sscanf(str.c_str()+i, "%2x%n", &k, &num) > 0)
                        {
                                i += num-1;
                                b = k;
                                pkt.data.push_back(b);
                        }
                }
        }
        else
        {
                for (int i = 0; i < str.size(); i++)
                {
                        pkt.data.push_back(str[i]);
                }
        }
        
        update_packet();
}
示例#4
0
void ApplicationList::onDragDataGet(const Glib::RefPtr<Gdk::DragContext>& context, 
                             Gtk::SelectionData& data, guint info, guint time)
{
    Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = m_TreeView.get_selection();
    Gtk::TreeModel::iterator iter = refTreeSelection->get_selected();

    if(iter && ((*iter)[m_appColumns.m_col_type] == MODULE))
    {
        Glib::ustring name = (*iter)[m_appColumns.m_col_name];
        data.set(data.get_target(), MODULE,
                (const guchar*)name.c_str(), name.size()+1);  
    }
    else if(iter && ((*iter)[m_appColumns.m_col_type] == RESOURCE))
    {
        Glib::ustring name = (*iter)[m_appColumns.m_col_name];
        data.set(data.get_target(), RESOURCE,
                (const guchar*)name.c_str(), name.size()+1);  
    }
    else if(iter && ((*iter)[m_appColumns.m_col_type] == APPLICATION))
    {
        Glib::ustring name = (*iter)[m_appColumns.m_col_name];
        data.set(data.get_target(), APPLICATION,
                (const guchar*)name.c_str(), name.size()+1);  
    }
}
示例#5
0
Glib::ustring MyComboBox::convertText(Glib::ustring inputText) {
	int pos = inputText.find_last_of('/');
	Glib::ustring text = inputText;
	int max = 0;
	if ((pos >= 0) && (inputText.size() > (unsigned) pos)) {
		max = (inputText.size() - (pos + 1)) > 50 ?
				50 : (inputText.size() - (pos + 1));
		text = Glib::ustring(inputText, ++pos, max);
	}
	return text;
}
示例#6
0
void ModulePropertyWindow::updateParamteres()
{
    // updating parameters
    typedef Gtk::TreeModel::Children type_children;
    type_children children = m_refTreeModel->children();
    OSTRINGSTREAM strParams;
    Glib::ustring strName;
    for(type_children::iterator iter = children.begin(); iter!=children.end(); ++iter)
    {
        strName = Glib::ustring((*iter)[m_Columns.m_col_name]);
        if(strName == "Parameters")
        {
            for(type_children::iterator jter = (*iter).children().begin(); 
                jter!=(*iter).children().end(); ++jter)
            {
                Glib::ustring strItem = Glib::ustring((*jter)[m_Columns.m_col_name]);
                Glib::ustring strValue = Glib::ustring((*jter)[m_Columns.m_col_value]);
                for(int i=0; i<m_pModule->argumentCount(); i++) 
                {
                    if(strItem == m_pModule->getArgumentAt(i).getParam())
                    {   
                        if(strValue.size())
                        {
                            if(!m_pModule->getArgumentAt(i).isSwitch())                            
                                strParams<<"--"<<strItem<<" "<<strValue<<" ";
                            else
                            {
                                if(compareString(strValue.c_str(), "on" ))
                                    strParams<<"--"<<strItem<<" ";
                                else
                                    (*jter)[m_Columns.m_col_value] = "off";
                            }
                        }
                        else
                            if(m_pModule->getArgumentAt(i).isSwitch())                            
                                (*jter)[m_Columns.m_col_value] = "off";
                    }    

                    if((strItem == m_pModule->getArgumentAt(i).getParam()) &&
                        m_pModule->getArgumentAt(i).isRequired())
                    {    
                        if(!strValue.size())
                            (*jter)[m_Columns.m_col_color_item] = Gdk::Color("#BF0303");
                        else
                            (*jter)[m_Columns.m_col_color_item] = Gdk::Color("#000000");
                    }
                }
            }
            (*iter)[m_Columns.m_col_value] = strParams.str();
            updateModule(strName.c_str(), strParams.str().c_str());
            break;
        }
    }        
}
示例#7
0
/*
 * Try to guess the DOI of the paper from the raw text
 */
void BibData::guessDoi (Glib::ustring const &graw)
{
	std::string const &raw = graw;
	boost::regex expression(
		"\\(?"
		"(?:"
		"(?:[Dd][Oo][Ii]:? *)"
		"|"
		"(?:[Dd]igital *[Oo]bject *[Ii]denti(?:fi|ямБ)er:? *)"
		")"
		"("
		"[^\\.\\s]+"
		"\\."
		"[^\\/\\s]+"
		"\\/"
		"[^\\s]+"
		")"
	);

	std::string::const_iterator start, end;
	start = raw.begin();
	end = raw.end();
	boost::match_results<std::string::const_iterator> what;
	boost::match_flag_type flags = boost::match_default;
	while(regex_search(start, end, what, expression, flags)) {
		Glib::ustring wholeMatch = std::string(what[0]);
		Glib::ustring gstr = std::string(what[1]);

		// Special case to chop off trailing comma to deal with
		// "doi: foo, available online" in JCompPhys
		// Note that commas ARE legal suffix characters in Doi spec
		// But there's nothing in the spec about regexing them
		// out of PDFS :-) -jcs
		if (gstr[gstr.size() - 1] == ',') {
			gstr = gstr.substr (0, gstr.size() - 1);
		};

		/*
		 * Special case to chop off trailing parenthesis
		 * in (doi:foo.foo/bar) case
		 */
		if (wholeMatch[0] == '(' && wholeMatch[wholeMatch.size() - 1] == ')') {
			gstr = gstr.substr (0, gstr.size() - 1);
		}

		setDoi (gstr);
		return;
	}
}
示例#8
0
void MainWindow::on_button_ipsw(){
/**********************************************************/
/*
 * Called when a new file has been selected
 */
	/* open file */
	cout 	<< endl<<"New file selected: " << filechooserbutton.get_filename() << endl;
	file.set_file(filechooserbutton.get_filename()); //open ipsw

	/* display the firmware information on the progressbar */
	std::stringstream text;
	text << file.get_ProductType() << " " << file.get_ProductVersion() << " (" << file.get_ProductBuildVersion() << ")" ;
	m_ProgressBar.set_text(text.str());

	/* retrieve the key */
	cout << "retreiving key." << endl;
	Glib::ustring k = GetKey(file);
	if(!k.size()){
		/* key not found */
		m_key.set_text("");
		text << " - No key available, please enter key manually";
		m_ProgressBar.set_text(text.str());
	}
	else{
		/* key found */
		m_key.set_text(k);
	}

	/* reset progressbar */
	m_ProgressBar.set_fraction(0);
}
static void sp_common_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *value)
{
    SPCommonContext *ctx = SP_COMMON_CONTEXT(ec);
    Glib::ustring path = value->getEntryName();
    
    // ignore preset modifications
    static Glib::ustring const presets_path = ec->pref_observer->observed_path + "/preset";
    Glib::ustring const &full_path = value->getPath();
    if (full_path.compare(0, presets_path.size(), presets_path) == 0) return;

    if (path == "mass") {
        ctx->mass = CLAMP(value->getDouble(0.2), -1000.0, 1000.0);
    } else if (path == "wiggle") {
        ctx->drag = CLAMP((1 - value->getDouble(1 - DRAG_DEFAULT)), DRAG_MIN, DRAG_MAX); // drag is inverse to wiggle
    } else if (path == "angle") {
        ctx->angle = CLAMP(value->getDouble(), -90, 90);
    } else if (path == "width") {
        ctx->width = CLAMP(value->getDouble(0.1), -1000.0, 1000.0);
    } else if (path == "thinning") {
        ctx->vel_thin = CLAMP(value->getDouble(0.1), -1.0, 1.0);
    } else if (path == "tremor") {
        ctx->tremor = CLAMP(value->getDouble(), 0.0, 1.0);
    } else if (path == "flatness") {
        ctx->flatness = CLAMP(value->getDouble(1.0), 0, 1.0);
    } else if (path == "usepressure") {
        ctx->usepressure = value->getBool();
    } else if (path == "usetilt") {
        ctx->usetilt = value->getBool();
    } else if (path == "abs_width") {
        ctx->abs_width = value->getBool();
    } else if (path == "cap_rounding") {
        ctx->cap_rounding = value->getDouble();
    }
}
示例#10
0
 Glib::ustring string_substring(const Glib::ustring & source, int start)
 {
   DBG_ASSERT(start >= 0, "start can't be negative");
   if(source.size() <= (unsigned int)start) {
     return "";
   }
   return Glib::ustring(source, start, std::string::npos);
 }
示例#11
0
Glib::ustring base64encode(Glib::ustring url)
{
	const gchar* glou = url.c_str() ;
	const guchar* glop = (const guchar*) glou ;
	gchar* encoded = g_base64_encode(glop, url.size()) ;
	std::string encodeds = std::string(encoded) ;
	g_free(encoded) ;
	return encodeds ;
}
示例#12
0
void ModulePropertyWindow::onCellEdited(const Glib::ustring& path_string, 
                    const Glib::ustring& new_text)
{
    if(!m_pModule)
        return;

    if(m_pAppWindow)
        m_pAppWindow->setModified();

    ErrorLogger* logger = ErrorLogger::Instance();
    Gtk::TreePath path(path_string);

    //Get the row from the path:
    Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path);
    if(iter)
    {
        Gtk::TreeModel::Row row = *iter;
        //Put the new value in the model:
        Glib::ustring strName = Glib::ustring(row[m_Columns.m_col_name]);

        if(strName == "Deployer")
        {
            if(strlen(m_pModule->getHost()) && 
               !compareString(m_pModule->getHost(), "localhost") && 
               (new_text == "local"))
            {
                logger->addWarning("local deployer cannot be used to deploy a module on the remote host.");
                m_pParent->reportErrors();
                return;
            }
        }

        if(strName == "Node")
        {
            if(compareString(m_pModule->getBroker(), "local") &&
               new_text.size() && (new_text != "localhost")) 
            {    
                OSTRINGSTREAM msg;
                msg<<new_text.c_str()<<" cannot be used with local deployer!";
                logger->addWarning(msg);
                m_pParent->reportErrors();
                
                Gtk::TreeModel::Row row;
                if(getRowByName("Deployer", &row))
                {
                    row[m_Columns.m_col_value] = "";
                    updateModule("Deployer", "");
                }
            } 
        }

        row[m_Columns.m_col_value] = new_text;
        updateParamteres();
        updateModule(strName.c_str(), new_text.c_str());

   }
}
Glib::RefPtr<Gdk::Pixbuf> imagecache___::cache__(const Glib::ustring& filename,int pix_limit_width,int pix_limit_height,bool pix_limit_aspect) {
    Glib::RefPtr<Gdk::Pixbuf> pb;
    if(filename.size()<1)
        return pb;
    item___* item=new item___(filename,pix_limit_width,pix_limit_height,pix_limit_aspect);
    Glib::ustring name=cachename__(filename,pix_limit_width,pix_limit_height,pix_limit_aspect);
    cache_[name]=item;
    return item->pb__();
}
示例#14
0
Glib::ustring replace_in_string(Glib::ustring data, Glib::ustring toBeReplaced, Glib::ustring replace)
{
	guint pos = 0 ;
	int size = toBeReplaced.size() ;
	pos = data.find(toBeReplaced) ;
	while ( pos!= string::npos ) {
		data.replace(pos, size, replace) ;
		pos = data.find(toBeReplaced) ;
	}
	return data ;
}
示例#15
0
文件: gx_main.cpp 项目: dafx/guitarix
void ErrorPopup::on_message(const Glib::ustring& msg_, GxLogger::MsgType tp, bool plugged) {
    if (plugged) {
	return;
    }
    if (tp == GxLogger::kError) {
	if (active) {
	    msg += "\n" + msg_;
	    if (msg.size() > 1000) {
		msg.substr(msg.size()-1000);
	    }
	    if (dialog) {
		dialog->set_message(msg);
	    }
	} else {
	    msg = msg_;
	    active = true;
	    show_msg();
	}
    }
}
示例#16
0
/**
    Replace font family leaving style alone (if possible).
    @param fontSpec the given font
    @param newFamily
    @return the changed fontspec, if the property can not be set return an empty string
    The routine first searches for an exact match.
    If no exact match found, calls FontSpecificationBestMatch().
*/
Glib::ustring font_factory::ReplaceFontSpecificationFamily(const Glib::ustring & fontSpec, const Glib::ustring & newFamily)
{
    Glib::ustring newFontSpec;

    // Although we are using the string from pango_font_description_to_string for the
    // font specification, we definitely cannot just set the new family in the
    // PangoFontDescription structure and ask for a new string.  This is because
    // what constitutes a "family" in our own UI may be different from how Pango
    // sees it.

    // Find the PangoFontDescription associated with the old font specification string.
    PangoStringToDescrMap::iterator it = fontInstanceMap.find(fontSpec);


    if (it != fontInstanceMap.end()) {
        // Description found!

        // Make copy
        PangoFontDescription *descr = pango_font_description_copy((*it).second);

        // Grab the old UI Family string from the descr
        Glib::ustring uiFamily = GetUIFamilyString(descr);

        // Replace the UI Family name with the new family name
        std::size_t found = fontSpec.find(uiFamily);
        if (found != Glib::ustring::npos) {

            // Add comma to end of newFamily... commas at end don't hurt but are
            // required if the last part of a family name is a valid font style
            // (e.g. "Arial Black").
            Glib::ustring newFamilyComma = newFamily;
            if( *newFamilyComma.rbegin() != ',' ) {
                newFamilyComma += ",";
            }
            newFontSpec = fontSpec;
            newFontSpec.erase(found, uiFamily.size());
            newFontSpec.insert(found, newFamilyComma);

            // If the new font specification does not exist in the reference maps,
            // search for the next best match for the faces in that style
            it = fontInstanceMap.find(newFontSpec);
            if (it == fontInstanceMap.end()) {

                // Search for best match, empty string returned if not found.
                newFontSpec = FontSpecificationBestMatch( newFontSpec );

            }
        }

        pango_font_description_free(descr);
    }

    return newFontSpec;
}
示例#17
0
void MainWindow::Decrypt(){
/**********************************************************/
/*
 * This will be started as a new thread when the decrypt button is selected.
 * The encrypted dmg inside the ipsw will be extracted.
 */
	std::stringstream output;

	/* reset the decryption status
	 * this will be updated by vfdecrypt
	 */
	decrypt_progress = 0;

	/* console data: print the input file and the location of the decrypted dmg file */
	std::cout << filechooserbutton.get_filename() << std::endl;
	output << filechooserbutton.get_current_folder() << "\\decrypted_" << file.get_SystemRestoreImage();
	std::cout << output.str() << std::endl;

	/* extract the root file system from ipsw */
	file.get_file(file.get_SystemRestoreImage());

	/* decrypt SystemRestoreImage */
	std::stringstream outfile;
	outfile << filechooserbutton.get_current_folder()
			<< "\\" << file.get_ProductType()
			<< "_" << file.get_ProductVersion()
			<< "_" << file.get_ProductBuildVersion()
			<< "_Decrypted_"
			<< file.get_SystemRestoreImage().c_str();

	Glib::ustring keystring = GetKey(file).c_str();

	if(!keystring.size() && m_key.get_text().size())
		keystring = m_key.get_text();


	decrypt(
		(char *)file.get_SystemRestoreImage().c_str(),		/* root file system image name */
		(char *)outfile.str().c_str(),						/* output location and name */
		(char *)keystring.c_str(),						/* try to obtain the decryption key */
		NULL												/* passphrase not used*/
	);

	/* remove the encrypted file */
	if( std::remove( file.get_SystemRestoreImage().c_str() ) != 0 )
		std::cout << "Error deleting " << file.get_filename() << std::endl;

	/* stop decrypting */
	decrypting = 0;

	/* enable the decryption button */
	Button_Decrypt.set_sensitive(true);
}
示例#18
0
文件: trie.hpp 项目: haobug/gnote
  void add_keyword(const Glib::ustring & keyword, const value_t & pattern_id)
  {
    TrieStatePtr current_state = m_root;

    for (Glib::ustring::size_type i = 0; i < keyword.size(); i++) {
      gunichar c = keyword[i];
      if (!m_case_sensitive)
        c = Glib::Unicode::tolower(c);

      TrieStatePtr target_state = find_state_transition(current_state, c);
      if (0 == target_state) {
        target_state = TrieStatePtr(new TrieState(c, i, m_root));
        current_state->transitions().push_front(target_state);
      }

      current_state = target_state;
    }

    current_state->payload(pattern_id);
    current_state->payload_present(true);
    m_max_length = std::max(m_max_length, keyword.size());
  }
示例#19
0
/**
 * Set the string value of a key/name registry entry
 */ 
bool RegistryTool::setStringValue(const Glib::ustring &keyNameArg,
                                  const Glib::ustring &valueName,
                                  const Glib::ustring &value)
{
    Glib::ustring keyName = keyNameArg;
    bool ret = false;

    HKEY rootKey = HKEY_LOCAL_MACHINE; //default root
    //Trim out the root key if necessary
    for (KeyTableEntry *entry = keyTable; entry->key; entry++)
        {
        if (keyName.compare(0, entry->strlen, entry->str)==0)
            {
            rootKey = entry->key;
            keyName = keyName.substr(entry->strlen);
            }
        }
    //printf("trimmed string: '%s'\n", keyName.c_str());

    //Get or create the key
    gunichar2 *keyw       = g_utf8_to_utf16(keyName.data(), -1, 0,0,0);
    gunichar2 *valuenamew = g_utf8_to_utf16(valueName.data(), -1, 0,0,0);

    HKEY key;
    if (RegCreateKeyExW(rootKey, (WCHAR*) keyw,
                       0, NULL, REG_OPTION_NON_VOLATILE,
                       KEY_WRITE, NULL, &key, NULL))
    {
       fprintf(stderr, "RegistryTool: Could not create the registry key '%s'\n", keyName.c_str());
       goto fail;
    }

    // Set the value
    if (RegSetValueExW(key, (WCHAR*) valuenamew,
          0,  REG_SZ, (LPBYTE) value.data(), (DWORD) (value.size() + 1)))
    {
       fprintf(stderr, "RegistryTool: Could not set the value '%s'\n", value.c_str());
       goto failkey;
    }

    ret = true;
    
    failkey:
    RegCloseKey(key);
    
    fail:
    g_free(keyw);
    g_free(valuenamew);
    return ret;
}
示例#20
0
void strTo(const Glib::ustring& p_str, T p_out){
	int l_pos;
	unsigned int l_oldpos;
	std::stringstream l_str;
	Q l_ret;

	// Si la cadena no contiene nada, terminamos
	if(p_str.size() == 0)
		return;

	// Puntero de cabecera y cola en la cadena
	l_oldpos = 0;
	l_pos = p_str.find("," , 0);
	// Si hay cadenas
	while(l_pos > -1){
		// Convertimos y añadimos la substring
		l_str.clear();
		l_str << p_str.substr(l_oldpos, l_pos - l_oldpos).c_str();
		l_str >> l_ret;
		*p_out++ = l_ret;

		// Saltamos , o ", "
		if(p_str[l_pos + 1] == ' ')
			l_oldpos = l_pos + 2;
		else
			l_oldpos = l_pos + 1;
		// Buscamos la siguiente ","
		l_pos = p_str.find("," , l_oldpos);
	}

	if(l_oldpos != p_str.size()){
		// Convertimos y añadimos la substring
		l_str.clear();
		l_str << p_str.substr(l_oldpos, p_str.size()).c_str();
		l_str >> l_ret;
		*p_out = l_ret;
	}
示例#21
0
int CProcess::errReadLine(Glib::ustring& p_text){
	Glib::IOStatus l_status;

	if (m_proc_id != -1){
		try{
			l_status = m_channel_err->read_line(p_text);
			if((l_status == Glib::IO_STATUS_EOF) || (l_status == Glib::IO_STATUS_ERROR))
				return -1;
			return p_text.size();
		}
		catch(const Glib::Exception& l_exception){
			GELIDE_ERROR("Reading from process (" << l_exception.what().c_str() << ")");
			return -1;
		}
	}
	return -1;
}
示例#22
0
文件: trie.hpp 项目: haobug/gnote
  typename TrieHit<value_t>::ListPtr find_matches (const Glib::ustring & haystack)
  {
    TrieStatePtr current_state = m_root;
    typename TrieHit<value_t>::ListPtr matches(
      new typename TrieHit<value_t>::List());
    int start_index = 0;

    for (Glib::ustring::size_type i = 0; i < haystack.size(); i++) {
      gunichar c = haystack[i];
      if (!m_case_sensitive)
        c = Glib::Unicode::tolower(c);

      if (current_state == m_root)
        start_index = i;

      // While there's no matching transition, follow the fail states
      // Because we're potentially changing the depths (aka length of
      // matched characters) in the tree we're updating the start_index
      // accordingly
      while ((current_state != m_root)
             && 0 == find_state_transition(current_state, c)) {
        TrieStatePtr old_state = current_state;
        current_state = current_state->fail_state();
        start_index += old_state->depth() - current_state->depth();
      }

      current_state = find_state_transition (current_state, c);
      if (0 == current_state)
        current_state = m_root;

      // If the state contains a payload: We've got a hit
      // Return a TrieHit with the start and end index, the matched
      // string and the payload object
      if (current_state->payload_present()) {
        int hit_length = i - start_index + 1;
        typename TrieHit<value_t>::Ptr hit(
          new TrieHit<value_t>(start_index,
                               start_index + hit_length,
                               haystack.substr(start_index, hit_length),
                               current_state->payload()));
        matches->push_back(hit);
      }
    }

    return matches;
  }
示例#23
0
/* --------------------------------------------------------------*/
void Modem::update_modem_name()
{
    size_t i;
    Glib::ustring modemName = this->modemNameCombobox->get_active_text();

    for (i = 0; modemName.compare(modems[i]->name()) && i < modems.size(); ++i) {
        currentModem = static_cast<modemModel_t>(i);
    }
    currentModem = static_cast<modemModel_t>(i);

    if(i >= modemName.size()) {
        Log::LogWarn(LEVEL_LOG_WARNING, "wrong modem configuration, setting to default", __FILE__, __LINE__);
        this->currentModem = DEFAULT;
    }

    this->populate_mode_combobox();
}
示例#24
0
void CLGUI::on_cl_button_click_event()
{
   Glib::ustring utxt = txtGet->get_text();
   int len = utxt.size();
   const char* chtxt = utxt.data();

   String* str = new String(chtxt);
   delete[] chtxt;
   int index = str->a_to_i();
   delete str;

   int size = cl->size();
   if (index >= 1 && index <= size)
   {
      cl->remove(index);
   }
   update();
}
示例#25
0
/**
 * Set the string value of a key/name registry entry
 */ 
bool RegistryTool::setStringValue(const Glib::ustring &keyNameArg,
                                  const Glib::ustring &valueName,
                                  const Glib::ustring &value)
{
    Glib::ustring keyName = keyNameArg;

    HKEY rootKey = HKEY_LOCAL_MACHINE; //default root
    //Trim out the root key if necessary
    for (KeyTableEntry *entry = keyTable; entry->key; entry++)
        {
        if (keyName.compare(0, entry->strlen, entry->str)==0)
            {
            rootKey = entry->key;
            keyName = keyName.substr(entry->strlen);
            }
        }
    //printf("trimmed string: '%s'\n", keyName.c_str());

    //Get or create the key
    HKEY key;
    if (RegCreateKeyEx(rootKey, keyName.c_str(),
                       0, NULL, REG_OPTION_NON_VOLATILE,
                       KEY_WRITE, NULL, &key, NULL))
       {
       fprintf(stderr, "RegistryTool: Could not create the registry key '%s'\n", keyName.c_str());
       return false;
       }

    //Set the value
    if (RegSetValueEx(key, valueName.c_str(),
          0,  REG_SZ, (LPBYTE) value.c_str(), (DWORD) value.size()))
       {
       fprintf(stderr, "RegistryTool: Could not set the value '%s'\n", value.c_str());
       RegCloseKey(key);
       return false;
       }


    RegCloseKey(key);

    return true;
}
示例#26
0
bool CDatReaderLogiqxXml::open(const Glib::ustring& p_file){
	CXmlNode l_node;

	// El fichero debe ser válido
	assert(p_file.size());

	// Reseteamos si es necesario
	if(m_loaded)
		reset();

	if(m_reader.open(p_file)){
		// Comprobamos si el primer nodo es "datafile"
		l_node = m_reader.getRootElement();
		if(l_node.getName() == "datafile"){
			m_loaded = true;
			parseHeaderBlock();
			return true;
		}
	}
	return false;
}
示例#27
0
IndigoLogger::Logger::Logger(Glib::ustring prefix)
	: category(log4cpp::Category::getInstance(prefix+"Category")) {
	if(init.find(prefix) == init.end()){
		Glib::ustring path;
		config.get(IndigoConfig::LOGPATH, path);
		if(path.c_str()[path.size()] != '/')
			path+="/";
		Glib::ustring name;
		config.get(IndigoConfig::LOGFILENAME, name);
		struct timeval tv;
		gettimeofday(&tv,NULL);
		name = path + prefix + name + ".log";
		init[prefix] = true;
		log4cpp::Appender *appender = new log4cpp::FileAppender(prefix+"FileAppender", name, false);
		log4cpp::Layout *layout = new log4cpp::BasicLayout();

		appender->setLayout(layout);
		category.setAppender(appender);
		category.setPriority(log4cpp::Priority::DEBUG);
	}
}
void ColorNotebook::_rgbaEntryChanged(GtkEntry* entry)
{
    if (_updating) return;
    if (_updatingrgba) return;

    const gchar *t = gtk_entry_get_text( entry );

    if (t) {
        Glib::ustring text = t;
        bool changed = false;
        if (!text.empty() && text[0] == '#') {
            changed = true;
            text.erase(0,1);
            if (text.size() == 6) {
                // it was a standard RGB hex
                unsigned int alph = SP_COLOR_F_TO_U(_alpha);
                gchar* tmp = g_strdup_printf("%02x", alph);
                text += tmp;
                g_free(tmp);
            }
        }
        gchar* str = g_strdup(text.c_str());
        gchar* end = 0;
        guint64 rgba = g_ascii_strtoull( str, &end, 16 );
        if ( end != str ) {
            ptrdiff_t len = end - str;
            if ( len < 8 ) {
                rgba = rgba << ( 4 * ( 8 - len ) );
            }
            _updatingrgba = TRUE;
            if ( changed ) {
                gtk_entry_set_text( entry, str );
            }
            SPColor color( rgba );
            setColorAlpha( color, SP_RGBA32_A_F(rgba), true );
            _updatingrgba = FALSE;
        }
        g_free(str);
    }
}
示例#29
0
void JsCompressorFrame::evt_executeBtn_clicked() {
	if (this->m_root_path_entry.get_text_length() <= 0) {
		return;
	}
	this->init_logfile();
	this->iter_filelist();
	Glib::ustring targetFiles;
	size_t length = files.size();
	for (size_t k = 0; k < length; k++) {
		targetFiles.append(";");
		targetFiles.append(files[k]);
	}

	Glib::ustring cmd;
	if (OS_IS_WINDOWS) {
		cmd.append("\"");
		cmd.append(tinyms::FileUtils::__APSPATH__);
		cmd.append("/jre6/bin/javaw.exe\" -jar compressorhelper.jar");
	} else {
		cmd.append("java -jar compressorhelper.jar");
	}
	cmd.append(" -selected-folder ");
	cmd.append(this->m_root_path_entry.get_text());
	cmd.append(" -files ");
	cmd.append(targetFiles.substr(1, targetFiles.size()));
	cmd.append(" -type ");
	if (this->m_jsOrCssChkbox.get_active()) {
		cmd.append("css");
	} else {
		cmd.append("js");
	}
	cmd.append(" -aio ");
	cmd.append("true");
	system(cmd.c_str());
	std::cout << cmd << std::endl;

	this->read_logfile();

}
示例#30
0
bool area___::expose_evt__(GdkEventExpose* event){
	if(code_.size()>0){
		Glib::RefPtr<Gdk::Window> window=da_->get_window();
		if(window){
			cr_ = window->create_cairo_context();
			if(event){
				cr_->rectangle(event->area.x, event->area.y,
						event->area.width, event->area.height);
				cr_->clip();
			}

#ifdef debug_
			test__();
#else
			char buf[32];
			l2s__((long)this,buf);
			d_(sh_,on_,code_.c_str(),NULL,3,ht_->name__(),"重绘",buf);
#endif
		}
		return true;
	}
	return false;
}