void Gxmetal_ampGUI::set_skin() { Glib::ustring toparse = "pixmap_path "; toparse += " '"; toparse += GX_LV2_STYLE_DIR; toparse += "/'\n"; toparse += "style \"gx_"; toparse += plug_name; toparse += "_dark-paintbox\"\n" " { \n" "GxPaintBox::skin-gradient = {\n" "{ 65536, 0, 0, 13107, 52428 }, \n" "{ 52428, 0, 0, 0, 52428 },\n" "{ 13107, 0, 0, 13107, 13107 }}\n" " GxPaintBox::icon-set =4\n" " stock['amp_skin'] = {{'"; toparse += plugskin; toparse += "'}}\n" " }\n" "\n" "style 'gx_headmetal_amp_box' \n" " { \n" " fg[NORMAL] = '#cbc8c8' \n" "font_name = 'sans bold 9.5' \n" " }\n"; toparse += addKnob; toparse += " widget '*.amplabel' style:highest 'gx_headmetal_amp_box'\n" "widget '*."; toparse += plug_name; toparse += "' style 'gx_"; toparse += plug_name; toparse += "_dark-paintbox' "; toparse += "style 'gx_switch'\n" "{\n" "xthickness = 0\n" "ythickness = 0\n" "GtkButton::inner-border = {0, 0, 0, 0}\n" "GtkButton::default-border = {0, 0, 0, 0}\n" "GtkButton::focus-line-width = 0\n" "GtkButton::focus-padding = 0\n" "GtkButton::interior-focus = 0\n" "GtkButton::child-displacement-x = 0\n" "GtkButton::child-displacement-y = 0\n" " }\n" "widget '*."; toparse += plug_name; toparse += "' style:highest 'gx_switch'"; gtk_rc_parse_string (toparse.c_str()); }
Glib::ustring get_file_save_path (SPDocument *doc, FileSaveMethod method) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring path; bool use_current_dir = true; switch (method) { case FILE_SAVE_METHOD_SAVE_AS: { use_current_dir = prefs->getBool("/dialogs/save_as/use_current_dir", true); if (doc->getURI() && use_current_dir) { path = Glib::path_get_dirname(doc->getURI()); } else { path = prefs->getString("/dialogs/save_as/path"); } break; } case FILE_SAVE_METHOD_TEMPORARY: path = prefs->getString("/dialogs/save_as/path"); break; case FILE_SAVE_METHOD_SAVE_COPY: use_current_dir = prefs->getBool("/dialogs/save_copy/use_current_dir", prefs->getBool("/dialogs/save_as/use_current_dir", true)); if (doc->getURI() && use_current_dir) { path = Glib::path_get_dirname(doc->getURI()); } else { path = prefs->getString("/dialogs/save_copy/path"); } break; case FILE_SAVE_METHOD_INKSCAPE_SVG: if (doc->getURI()) { path = Glib::path_get_dirname(doc->getURI()); } else { // FIXME: should we use the save_as path here or something else? Maybe we should // leave this as a choice to the user. path = prefs->getString("/dialogs/save_as/path"); } break; case FILE_SAVE_METHOD_EXPORT: /// \todo no default path set for Export? // defaults to g_get_home_dir() break; } if(path.empty()) { path = g_get_home_dir(); // Is this the most sensible solution? Note that we should avoid // g_get_current_dir because this leads to problems on OS X where // Inkscape opens the dialog inside application bundle when it is // invoked for the first teim. } return path; }
void tokenizeWords(const Glib::ustring& str, std::vector<Glib::ustring>& container) { ustring::size_type lastPos = str.find_first_not_of(' ', 0); ustring::size_type pos = str.find_first_of(' ', lastPos); while (ustring::npos != pos || ustring::npos != lastPos) { container.push_back(str.substr(lastPos, pos - lastPos)); lastPos = str.find_first_not_of(' ', pos); pos = str.find_first_of(' ', lastPos); } }
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; }
void NoteDirectoryWatcherApplicationAddin::delete_note(const Glib::ustring & note_id) { DBG_OUT("NoteDirectoryWatcher: deleting %s because file deleted.", note_id.c_str()); Glib::ustring note_uri = make_uri(note_id); gnote::NoteBase::Ptr note_to_delete = note_manager().find_by_uri(note_uri); if(note_to_delete != 0) { note_manager().delete_note(note_to_delete); } else { DBG_OUT("notedirectorywatcher: did not delete %s because note not found.", note_id.c_str()); } }
gchar * sp_repr_css_write_string(SPCSSAttr *css) { Glib::ustring buffer; for ( List<AttributeRecord const> iter = css->attributeList() ; iter ; ++iter ) { if (iter->value && !strcmp(iter->value, "inkscape:unset")) { continue; } buffer.append(g_quark_to_string(iter->key)); buffer.push_back(':'); if (!strcmp(g_quark_to_string(iter->key), "font-family") || !strcmp(g_quark_to_string(iter->key), "-inkscape-font-specification")) { // we only quote font-family/font-specification, as SPStyle does gchar *t = g_strdup (iter->value); g_free (t); gchar *val_quoted = css2_escape_quote (iter->value); if (val_quoted) { buffer.append(val_quoted); g_free (val_quoted); } } else { buffer.append(iter->value); // unquoted } if (rest(iter)) { buffer.push_back(';'); } } return (buffer.empty() ? NULL : g_strdup (buffer.c_str())); }
virtual void on_end_element ( Glib::Markup::ParseContext& context, const Glib::ustring& element) { if (Glib::str_has_prefix (text_, "<![CDATA[") && Glib::str_has_suffix (text_, "]]>")) { text_ = text_.substr (strlen ("<![CDATA["), text_.length () - strlen ("<![CDATA[" "]]>")); } if (element == "doi") { bib_.setDoi (text_); } else if (element == "article_title") { bib_.setTitle (text_); /* FIXME: assuming given_name precedes surname */ } else if (element == "given_name") { given_name_ = text_; } else if (element == "surname") { if (!given_name_.empty()) { text_ = text_ + ", " + given_name_; given_name_ = ""; } authors_.push_back (text_); } else if (element == "journal_title") { bib_.setJournal (text_); } else if (element == "volume") { bib_.setVolume (text_); } else if (element == "issue") { bib_.setIssue (text_); } else if (element == "first_page") { bib_.setPages (text_); } else if (element == "year") { bib_.setYear (text_); } else if (element == "volume_title") { bib_.addExtra ("BookTitle", text_); } else if (element == "body") { /* End of entry */ Glib::ustring authorString; std::vector<Glib::ustring>::iterator it = authors_.begin (); for (; it != authors_.end(); ++it) { if (it != authors_.begin()) { authorString += " and "; } authorString += *it; } if (!authorString.empty()) bib_.setAuthors (authorString); } }
void Settings::on_server_apply() { Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = m_list_servers->get_selection(); Gtk::TreeModel::iterator iter = refTreeSelection->get_selected(); if(!iter) { return; } Gtk::TreeModel::Row row = *iter; if(m_server_detail_server->is_sensitive()) { row[m_Columns.m_hostname] = m_server_detail_server->get_text(); } if(m_server_detail_aet->is_sensitive()) { row[m_Columns.m_aet] = m_server_detail_aet->get_text(); } if(m_server_detail_port->is_sensitive()) { guint i = atoi(m_server_detail_port->get_text().c_str()); row[m_Columns.m_port] = i; } if(m_server_detail_group->is_sensitive()) { row[m_Columns.m_group] = m_server_detail_group->get_entry()->get_text(); } if(m_server_detail_description->is_sensitive()) { Glib::ustring desc = m_server_detail_description->get_text(); row[m_Columns.m_name] = desc; if(desc.empty()) { m_settings_ok->set_sensitive(false); } else { m_settings_ok->set_sensitive(true); } } if(m_server_detail_lossy->is_sensitive()) { row[m_Columns.m_lossy] = m_server_detail_lossy->get_active(); } if(m_server_detail_relational->is_sensitive()) { row[m_Columns.m_relational] = m_server_detail_relational->get_active(); } // enable echo button if(!m_server_detail_aet->get_text().empty() && !m_server_detail_server->get_text().empty() && !m_server_detail_port->get_text().empty()) { m_server_detail_echo->set_sensitive(true); } else { m_server_detail_echo->set_sensitive(false); } }
/* * Search function for widget. * Returns true if entered text matches contact address or nickname. */ bool ContactsTreeWidget::onSearchEqual(const Glib::RefPtr<Gtk::TreeModel>& model, gint column, const Glib::ustring& key, const Gtk::TreeModel::iterator& iter) { Gtk::TreeModel::Row row = *iter; if (row[columns.contactIndex] >= 20 && row[columns.contactIndex] != GROUP_INDEX_NOT_AUTHORIZED) { Glib::ustring x; x = row[columns.contactAddress]; if (x.find(key) != Glib::ustring::npos) { return false; } x = row[columns.contactNickname]; if (x.find(key) != Glib::ustring::npos) { return false; } } return true; }
std::string ParserXML::extractNodeName (const xmlpp::Node* node) const { const xmlpp::TextNode* nodeText = dynamic_cast<const xmlpp::TextNode*> (node); const xmlpp::CommentNode* nodeComment = dynamic_cast<const xmlpp::CommentNode*> (node); std::string readLine = ""; Glib::ustring nodename = node->get_name (); if (nodeText && (nodeText->is_white_space () || nodeText->get_content () == "")) return ""; if (!nodeText && !nodeComment && !nodename.empty ()) readLine = node->get_name (); return (readLine); }
bool post_office::push_data (Glib::ustring data) { if(connected) { /* Send the word to the server */ int len = strlen(data.c_str()); if (send(sock, data.c_str(), len, 0) != len) { this->set_last_error("Mismatch in number of sent bytes"); return false; } return true; } this->set_last_error("Not connected"); return false; }
//#ifdef ver_3_ void new_open__(const Glib::ustring& url,WebKitWebView* wwv){ Glib::ustring js; js= "var a=document.createElement('a');"//_x "a.setAttribute('href','"+url+"');" "a.setAttribute('target','_blank');" //"a.innerHTML='a';" //"var body=document.getElementsByTagName('body')[0];" //"body.appendChild(a);" "var me=document.createEvent('MouseEvents');" "me.initEvent('click',true,false);" "a.dispatchEvent(me);" ; webkit_web_view_execute_script (wwv, js.c_str()); }
void ManglerAudio::playText(Glib::ustring text) {/*{{{*/ if (!text.length() || !Mangler::config["NotificationTextToSpeech"].toBool()) { return; } #ifdef HAVE_ESPEAK espeak_SetSynthCallback(espeak_synth_cb); ManglerAudio *tts = new ManglerAudio(AUDIO_NOTIFY, mangler->espeakRate, 1, 0, 0, false); if (espeak_Synth(text.c_str(), text.length() + 1, 0, POS_CHARACTER, 0, espeakCHARS_AUTO, NULL, tts) != EE_OK) { tts->finish(); fprintf(stderr, "espeak: synth error\n"); return; } #endif }/*}}}*/
void PrintNotesNoteAddin::print_button_clicked(const Glib::VariantBase&) { try { m_print_op = Gtk::PrintOperation::create(); m_print_op->set_job_name(get_note()->get_title()); Glib::RefPtr<Gtk::PrintSettings> settings = Gtk::PrintSettings::create(); Glib::ustring dir = Glib::get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS); if (dir.empty()) { dir = Glib::get_home_dir(); } Glib::ustring ext; if (settings->get(Gtk::PrintSettings::Keys::OUTPUT_FILE_FORMAT) == "ps") { ext = ".ps"; } else { ext = ".pdf"; } Glib::ustring uri = "file://"; uri += dir + "/gnotes" + ext; settings->set (Gtk::PrintSettings::Keys::OUTPUT_URI, uri); m_print_op->set_print_settings (settings); m_print_op->signal_begin_print().connect( sigc::mem_fun(*this, &PrintNotesNoteAddin::on_begin_print)); m_print_op->signal_draw_page().connect( sigc::mem_fun(*this, &PrintNotesNoteAddin::on_draw_page)); m_print_op->signal_end_print().connect( sigc::mem_fun(*this, &PrintNotesNoteAddin::on_end_print)); m_print_op->run(Gtk::PRINT_OPERATION_ACTION_PRINT_DIALOG, *get_host_window()); } catch (const sharp::Exception & e) { DBG_OUT("Exception while printing %s: %s", get_note()->get_title().c_str(), e.what()); gnote::utils::HIGMessageDialog dlg(get_host_window(), GTK_DIALOG_MODAL, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, _("Error printing note"), e.what()); dlg.run (); } m_print_op.clear(); // yeah I really mean clear the pointer. }
bool ManglerAlsa::open(int type, Glib::ustring device, int rate, int channels) {/*{{{*/ if ((alsa_error = snd_pcm_open( &alsa_stream, (device == "") ? "default" : device.c_str(), (type >= AUDIO_OUTPUT) ? SND_PCM_STREAM_PLAYBACK : SND_PCM_STREAM_CAPTURE, 0)) < 0) { fprintf(stderr, "alsa: snd_pcm_open() failed: %s\n", snd_strerror(alsa_error)); alsa_stream = NULL; return false; } if ((alsa_error = snd_pcm_set_params( alsa_stream, // pcm handle SND_PCM_FORMAT_S16_LE, // format SND_PCM_ACCESS_RW_INTERLEAVED, // access channels, // channels rate, // rate true, // soft_resample 150000)) < 0) { // latency in usec (0.15 sec) fprintf(stderr, "alsa: snd_pcm_set_params() failed: %s\n", snd_strerror(alsa_error)); close(); return false; } if ((alsa_error = snd_pcm_prepare(alsa_stream)) < 0) { fprintf(stderr, "alsa: snd_pcm_prepare() failed: %s\n", snd_strerror(alsa_error)); close(); return false; } if (type == AUDIO_INPUT && (alsa_error = snd_pcm_start(alsa_stream)) < 0) { fprintf(stderr, "alsa: snd_pcm_start() failed: %s\n", snd_strerror(alsa_error)); close(); return false; } return true; }/*}}}*/
void CalligraphicProfileRename::show(SPDesktop *desktop, const Glib::ustring profile_name) { CalligraphicProfileRename &dial = instance(); dial._applied=false; dial._deleted=false; dial.set_modal(true); dial._profile_name = profile_name; dial._profile_name_entry.set_text(profile_name); if (profile_name.empty()) { dial.set_title(_("Add profile")); dial._delete_button.set_visible(false); } else { dial.set_title(_("Edit profile")); dial._delete_button.set_visible(true); } desktop->setWindowTransient (dial.gobj()); dial.property_destroy_with_parent() = true; // dial.Gtk::Dialog::show(); //dial.present(); dial.run(); }
/* Callback for receiving data from modem */ void Terminal::update_read(Glib::ustring data) { size_t iReplyOem; size_t iddot; size_t replyOemLen = strlen(this->modem->REPLY_OEM().c_str()); if(!data.is_ascii()) REMOVE_NON_ASCII(data); inputPortBuffer += data; while(!inputPortBuffer.empty()) { iReplyOem = inputPortBuffer.find(this->modem->REPLY_OEM()); iddot = inputPortBuffer.find(":"); if(iReplyOem == std::string::npos && iddot == std::string::npos) return; if(iReplyOem < iddot) { input.push(inputPortBuffer.substr(0, iReplyOem)); inputPortBuffer.erase(0, iReplyOem + replyOemLen); } else { input.push(inputPortBuffer.substr(0, iddot+1)); /* 1 == strlen(":") */ inputPortBuffer.erase(0, iddot + 1); /* 1 == strlen(":") */ } } }
/* compressed utf-8 table */ 0x20ac, /* 80 Euro. CP1252 from here on... */ 0x81, /* 81 NA */ 0x201a, /* 82 */ 0x192, /* 83 */ 0x201e, /* 84 */ 0x2026, /* 85 */ 0x2020, /* 86 */ 0x2021, /* 87 */ 0x2c6, /* 88 */ 0x2030, /* 89 */ 0x160, /* 8a */ 0x2039, /* 8b */ 0x152, /* 8c */ 0x8d, /* 8d NA */ 0x17d, /* 8e */ 0x8f, /* 8f NA */ 0x90, /* 90 NA */ 0x2018, /* 91 */ 0x2019, /* 92 */ 0x201c, /* 93 */ 0x201d, /* 94 */ 0x2022, /* 95 */ 0x2013, /* 96 */ 0x2014, /* 97 */ 0x2dc, /* 98 */ 0x2122, /* 99 */ 0x161, /* 9a */ 0x203a, /* 9b */ 0x153, /* 9c */ 0x9d, /* 9d NA */ 0x17e, /* 9e */ 0x178, /* 9f */ 0xa0, /* a0 */ 0xa1, /* a1 */ 0xa2, /* a2 */ 0xa3, /* a3 */ 0x20ac /* a4 ISO-8859-15 Euro. */ }; while (len) { if (G_UNLIKELY(*text >= 0x80) && G_UNLIKELY(*text <= 0xa4)) { int idx = *text - 0x80; output += lowtable[idx]; } else { output += (gunichar)*text; /* ascii/iso88591 maps directly */ } text++; len--; } return output; }/*}}}*/ void set_charset(Glib::ustring charset) {/*{{{*/ charset = charset.uppercase(); if (charset.find(' ') != Glib::ustring::npos) charset = charset.erase(charset.find(' ')); if (charset.empty() || !charset.compare("SYSTEM")) { charset.clear(); } else { try { Glib::IConv test("UTF-8", charset); } catch (...) { fprintf(stderr, "Charset '%s' isn't supported by your system - using system locale\n", charset.c_str()); charset.clear(); } } serverCharset = charset; }/*}}}*/ std::string ustring_to_c(Glib::ustring input) {/*{{{*/ std::string to_charset, converted; // check if input is already 7-bit if (input.is_ascii()) return input; // try encoding using the selected charset, unless its some utf-8 if (!serverCharset.empty() && serverCharset.find("UTF-8") == Glib::ustring::npos) { try { return Glib::convert(input, serverCharset, "UTF-8"); } catch (...) {} } // try encoding using the locale charset, unless its some utf-8 if (Glib::get_charset(to_charset) == true) to_charset = "ISO-8859-1"; try { converted = Glib::convert_with_fallback(input, to_charset, "UTF-8", "?"); } catch (...) { converted = input; } return converted; }/*}}}*/ Glib::ustring c_to_ustring(const char *input) {/*{{{*/ Glib::ustring converted, input_u; // if input is NULL, return an empty string if (! input) return ""; input_u = input; // check if input is already valid UTF-8 if (input_u.validate()) return input_u; // try to convert using the chosen charset if (!serverCharset.empty()) { try { return Glib::convert(input, "UTF-8", serverCharset); } catch (...) {} } // try to convert using the current locale try { converted = Glib::locale_to_utf8(input); } catch (...) { // locale conversion failed converted = iso_8859_1_to_utf8(input); } return converted; }/*}}}*/
void TextParam::param_setValue(const Glib::ustring newvalue) { value = newvalue; sp_canvastext_set_text (canvas_text, newvalue.c_str()); }
int main (int argc, char **argv) { Glib::thread_init(); Gtk::Main kit(argc, argv); Glib::ustring ces = argv[0]; Glib::ustring::size_type vzd = ces.rfind("/"); ces = Glib::ustring(ces.c_str(), ces.c_str()+vzd); int a = chdir(ces.c_str()); if(a != 0){ std::cerr<<"ERROR chdir: "<<a<<std::endl; } Okno *Hl = new Okno(); delete Hl; return 0; }
unsigned long XGPacketBuilder::parse_number(Glib::ustring str) { unsigned long l = 0; size_t n = str.find("0x"); if (n != std::string::npos) { l = std::strtol(str.substr(n).c_str(), 0, 16); } else { l = std::strtol(str.c_str(), 0, 10); } return l; }
bool PreferencesFrame::get_formatted_bool_dynamic_value(Glib::ustring value) { if (value.compare("true")==0) return true ; else return false ; }
Priority priority_from_string(const Glib::ustring& s) { if (s.compare(to_string(Priority::INVALID)) == 0) return Priority::INVALID; else if (s.empty()) return Priority::INVALID; else if (s.compare(to_string(Priority::LOW)) == 0) return Priority::LOW; else if (s.compare(to_string(Priority::MEDIUM)) == 0) return Priority::MEDIUM; else if (s.compare(to_string(Priority::HIGH)) == 0) return Priority::HIGH; else { std::cerr << "Error: Unknown Priority (" << s << ")" << std::endl; return Priority::INVALID; } }
void QRTestWidget::on_margin_edited (const Glib::ustring& str_path, const Glib::ustring& value) { Gtk::TreePath path(str_path); Gtk::TreeModel::iterator row = m_TestTreeModel->get_iter(path); if (row) (*row)[m_TestTreeModelColumns.m_margin] = atoi (value.c_str ()); }
bool Configuration::get_windowlevel_list(const Glib::ustring& modality, WindowLevelList& list) { HKEY hKey; DWORD ret; int serverIdx = 0; char desc[256]; std::string key = "SOFTWARE\\Aeskulap\\presets\\windowlevel\\" + modality ; if(modality.empty()) { return false; } ret = RegOpenKeyEx(HKEY_CURRENT_USER, key.c_str(), 0, KEY_READ | KEY_ENUMERATE_SUB_KEYS, &hKey); if( ret != ERROR_SUCCESS ) return false; list.clear(); while( RegEnumKey(hKey, serverIdx++, desc, sizeof(desc)) == ERROR_SUCCESS ) { WindowLevel w; if(get_windowlevel(modality, Glib::ustring(desc), w)) { list[w.description] = w; } } RegCloseKey(hKey); return true; }
bool AudioOpenAL::load_sound (SoundProfileImpl* prof, EffectType effect, const Glib::ustring& filename, vector<char>& data) const { MplayerDecoder dec; if (dec.open (filename)) { size_t pos = 0; size_t avai = data.size (); size_t read = dec.read (&data.data ()[pos], avai); size_t whole = 0; while (read == avai) { whole += read; size_t new_size = data.size () * 2 + 1; data.resize (new_size); pos += read; avai = data.size () - avai; read = dec.read (&data.data ()[pos], avai); } whole += read; ALuint sound_buffer; alGenBuffers (1, &sound_buffer); alBufferData (sound_buffer, dec.get_format (), data.data (), whole, dec.get_frequency ()); prof->buffers[effect].push_back (sound_buffer); return true; } logger.warnln ("could not play %s", filename.c_str ()); return false; }
Glib::ustring validate_utf(const Glib::ustring& string) { if(string.validate()) return string; else return m::convert(string, MLIB_UTF_CHARSET_NAME, MLIB_UTF_CHARSET_NAME); }
__time_t item___::tm__(const Glib::ustring& filename) { struct stat64 stt; if(stat64(filename.c_str(),&stt)==-1) return 0; else return stt.st_mtime; }
void ViCommandMode::execute(const Glib::ustring &cmd) { add_history( cmd ); char ch = cmd[0]; Glib::ustring rest = cmd.substr(1); if (ch == '/') { // // Forward search // execute_search(rest, ch); } else if (ch == '?') { // // Backward search // execute_search(rest, ch); } else if (ch == ':') { execute_command(rest); } }
chat_action::chat_action(Glib::PropertyProxy_ReadOnly<Glib::ustring> name, Glib::DateTime time, const Glib::ustring& text): m_label(name, time.to_local(), text) { utils::debug::scope_log log(DBG_LVL_1("gtox"), { name.get_value().raw(), time.format("%c").raw(), text.raw() }); m_username.show(); m_username.get_style_context()->add_class("gtox-action-username"); m_username.property_valign() = Gtk::ALIGN_START; m_username_binding = Glib::Binding::bind_property( name, m_username.property_label(), Glib::BINDING_DEFAULT | Glib::BINDING_SYNC_CREATE); show(); add(m_hbox); m_hbox.show(); m_hbox.add(m_username); m_hbox.add(m_label); property_reveal_child() = false; m_dispatcher.emit([this]() { utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); property_reveal_child() = true; }); }